Xcode with VFR Reader Download PDF Error

I use vfr / reader to open PDF files. When I open the first PDF file, my application opens it correctly, but when I open another, my application opens the first file again.

This is my function for reading a PDF file.

-(void)readIssue:(IssueMath *)issue { NSString *filePath = [[issue.contentURL path] stringByAppendingPathComponent:@"Mathematics.pdf"]; NSLog(@"Read Path 1: %@ ",filePath); ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath password:nil]; NSLog(@"Read Path 2: %@ ",document.fileURL); ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document]; readerViewController.delegate = self; // Set the ReaderViewController delegate to self readerViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; readerViewController.modalPresentationStyle = UIModalPresentationFullScreen; [self presentModalViewController:readerViewController animated:YES]; } 

And this is the NSLog output:

 2012-11-02 20:09:31.081 MAGAZINE[314:15203] Read Path 1: /Users/eakmotion/Library/Application Support/iPhone Simulator/5.0/Applications/EC25BC08-E1E7-44B6-9AD8-0A321EEAC8B6/Library/Caches/ISSUE3_2011/Mathematics.pdf 2012-11-02 20:09:31.109 MAGAZINE[314:15203] Read Path 2: file://localhost/Users/eakmotion/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/EC25BC08-E1E7-44B6-9AD8-0A321EEAC8B6/Library/Caches/ISSUE2_2011/Mathematics.pdf 

I want to read "ISSUE3_2011 / Mathematics.pdf", but the application still reads the first path "ISSUE2_2011 / Mathematics.pdf"

Why is filePath the same?

How can I solve this problem?

+1
source share
3 answers

Yes, your solution works, but if you want to keep track of all your pdf documents (for example, the current page is not)

You must specify unique names for your local PDF files. Because it will look for the Mathematics.plist file in the local device folder to read the current page number.

/ Users / eakmotion / Library / Application Support / iPhone Simulator / 5.0 / Applications / EC25BC08-E1E7-44B6-9AD8-0A321EEAC8B6 / Library / Caches / ISSUE3_2011 / Mathematics.pdf

file: //localhost/Users/eakmotion/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/EC25BC08-E1E7-44B6-9AD8-0A321EEAC8B6/Library/Caches/ISSUE2_2011/Mathematics.pdf

these files look for the same Mathematics.plist file in the ReaderDocument class method "unarchiveFromFileName"

 NSString *archivePath = [ReaderDocument applicationSupportPath]; // Application "~/Library/Application Support" path NSString *archiveName = [[filename stringByDeletingPathExtension] stringByAppendingPathExtension:@"plist"]; 

try changing this section of code or giving your files unique names such as Mathematics_ISSUE3_2011.pdf and Mathematics_ISSUE2_2011.pdf

+3
source

I know that this question is quite a few months, but just in case someone is experiencing the same problem (like me), I found a solution for it.

In the vfr / Reader source, locate the Sources/ReaderDocument.m and find the function named + (ReaderDocument *)withDocumentFilePath:

There, comment out a condition that prevents the document from reloading, as shown below.

 + (ReaderDocument *)withDocumentFilePath:(NSString *)filePath password:(NSString *)phrase { ReaderDocument *document = nil; // ReaderDocument object document = [ReaderDocument unarchiveFromFileName:filePath password:phrase]; //if (document == nil) // Unarchive failed so we create a new ReaderDocument object //{ document = [[ReaderDocument alloc] initWithFilePath:filePath password:phrase]; //} return document; } 

It was my quick and dirty approach to reload documents. The caveat to this solution is that the PDF reader will not keep track of where you left off in your pdf pages, which in my application did not matter.

+2
source

I ran into the same problem and found the following solution:

 // Path to first PDF file NSString *filePath = [[NSBundle mainBundle] pathForResource:@"someBookeName" ofType:@"pdf"]; 

Just change the file path as shown above. As you can see, now you do not need NSArray * PDF .

+1
source

All Articles