Hi,

I'm running into an issue with in-memory documents. I'm using Objective-C++ 
here, but I'm fairly certain that I'm doing everything correctly on the 
Objective-C part. I'm just wondering what I could be doing wrong trying to load 
the document. It works when loading the exact same document(s) using a file 
path, just not for the in-memory approach.

My current approach looks like this:

PdfMemDocument *document = new PdfMemDocument();
size_t length = [self.fileData length];
const char *bytes = (const char *)[self.fileData bytes];
document->Load(bytes, length);

This results in the following error:

PoDoFo encounter an error. Error: 16 ePdfError_NoEOFToken
        Error Description: No EOF Marker was found in the PDF file.
        Callstack:
        #0 Error Source: /path/to/podofo/src/base/PdfParser.cpp:209
                Information: Unable to load objects from file.
        #1 Error Source: /path/to/podofo/src/base/PdfParser.cpp:247
                Information: EOF marker could not be found.
        #2 Error Source: /path/to/podofo/src/base/PdfParser.cpp:1282

I've verified that bytes points to the correct content, and that the last five 
bytes actually are the EOF marker:

(gdb) po [NSString stringWithFormat:@"%c%c%c%c%c", bytes[length-5], 
bytes[length-4], bytes[length-3], bytes[length-2], bytes[length-1]]
%%EOF

As I said, I've tried this with various files and all of them work when 
accessed via the file system. Am I doing something wrong here? I've also tried 
other methods, using a PdfRefCountedInputDevice, even the istream method - but 
I always end up getting the same error.

Unfortunately, it is a requirement for this application to avoid using the file 
system, so I'm hoping someone will be able to tell me what I did wrong here.

Cheers,
Alex

--
Alexander Repty
Mac & iOS Software

http://alexrepty.com/
[email protected]
http://twitter.com/arepty


------------------------------------------------------------------------------
AppSumo Presents a FREE Video for the SourceForge Community by Eric 
Ries, the creator of the Lean Startup Methodology on "Lean Startup 
Secrets Revealed." This video shows you how to validate your ideas, 
optimize your ideas and identify your business strategy.
http://p.sf.net/sfu/appsumosfdev2dev
_______________________________________________
Podofo-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/podofo-users

Reply via email to