IOS vfr reader system cannot use downloaded pdf

I found the vfr framework by exploring some of the best alternatives for displaying pdf in an application. In my context, I need to download pdf; It is no longer included in the application package. It was easy to use the vfr framework with built-in pdf, but I was still at a dead end, forcing it to work with the downloaded data that I write to a file, and then initialize the ReaderDocument using this path. I can upload the same file to UIWebView without problems, so I do not believe this data. Here is the code:

NSString *fullPathToPDF = [[[self appDelegate] urlForFileUnderRecursiveDocWithName:self.pdfName andOptionallyStartingAtDirectory:[[self appDelegate] pathURLForImagesDirectory]] path]; ReaderDocument *pdfDoc = [ReaderDocument withDocumentFilePath:fullPathToPDF password:nil]; 

The result of pdfDoc will either be zero, or, passing it the full path, as indicated above, will fail with the statement from line 229 of the ReaderDocument

 NSAssert(NO, @"CGPDFDocumentRef == NULL"); 

because (I make a reasonable assumption) this line (217, same class):

 CGPDFDocumentRef thePDFDocRef = CGPDFDocumentCreateX(docURLRef, _password); 

Unable to create CGPDFDocumentRef. Earlier, I mentioned the difference between passing it the full path and just passing it the file name, but because, looking at the code, the ReaderDocument class seems to make some assumptions about where it expects to find the files. I was unable to get it to work no matter where I save the file, or what I pass to it ... with the DocumentFilePath method.

I repeat, I can use the same file and open it in UIWebView without any problems.

So, anyone who has this same problem, or can do what I'm trying to succeed? Thank you

0
source share
1 answer

Sorry for this so late. I just stumbled upon this problem, so I thought that I would pass my wisdom.

My guess: you are loading the PDF in a temporary directory. This structure looks for the file in NSDocumentDirectory. Therefore, when you go to save the downloaded file, just save a path like this:

 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *baseDocumentPath = [paths objectAtIndex:0]; NSString *filePath = [baseDocumentPath stringByAppendingPathComponent:@"/temp.pdf"]; 

Once you do this, it will load correctly.

ps If I end up modifying ReaderDocument to allow a temporary directory, I will post the changes here.

+5
source

All Articles