I found the vfr reader framework while looking into some better alternatives for displaying pdf in an app. In my context, I need to download a pdf; it's not included in the app bundle already. It was easy to use the vfr framework with an embedded pdf, but I've been stumped so far with getting it working with downloaded data that I write to a file, then init a ReaderDocument with it's path. I'm able to load the same file into a UIWebView no problem, so I don't believe it's the data. Here's the code:
NSString *fullPathToPDF = [[[self appDelegate] urlForFileUnderRecursiveDocWithName:self.pdfName andOptionallyStartingAtDirectory:[[self appDelegate] pathURLForImagesDirectory]] path];
ReaderDocument *pdfDoc = [ReaderDocument withDocumentFilePath:fullPathToPDF password:nil];
The resulting pdfDoc will either be null, or, when passing it the full path like above, will crash with an assertion from line 229 of ReaderDocument
NSAssert(NO, @"CGPDFDocumentRef == NULL");
because (I'm making a reasonable assumption) this line (217; same class):
CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateX(docURLRef, _password);
fails to create the CGPDFDocumentRef. I previously mentioned a distinction between passing it the full path vs just passing it the file name, and that's because in looking at the code, the ReaderDocument class appears to make some assumptions about where it expects to find the files. I haven't been able to get it working no matter where I save the file to, or what I pass into it's ...withDocumentFilePath method.
To reiterate, I'm able to use the exact same file and open it in a UIWebView no problem.
So, anybody having this same issue, or, able to do what I'm attempting successfully? Thanks.
Sorry to answer this so late. I just came across this problem myself so thought I'd pass along my wisdom.
My guess is you are downloading the PDF to the temporary directory. This framework is looking for the file in the NSDocumentDirectory. So when you go to save the downloaded file just save to a path like this:
Once you do that it will load correctly.
p.s If I end up modifying ReaderDocument to allow for a temporary directory I'll post the edits here.