objective-cpspdfkit

PSPDFKit Cannot get document reference (although file exists)


First of all, I'm using version 1.10.2

I'm having problems to open a pdf document.

NSURL* documentURL = [NSURL URLWithString:[[loader getPDFResourcePath:file] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
PSPDFDocument* document = [PSPDFDocument PDFDocumentWithUrl:documentURL];

PSPDFViewController* pdfController = [[PSPDFViewController alloc] initWithDocument:document];
[self presentModalViewController:pdfController animated:NO];

But I'm getting these error codes:

Oct 16 14:35:52 device-07 MODULESTEST[5150] <Error>: CFURLCreateDataAndPropertiesFromResource: failed with error code -15.
2012-10-16 14:35:52.217 MODULESTEST[5150:707] Error: -[PSPDFGlobalLock documentProviderForDocument:page:]/246 Cannot get document reference (although file exists) for /var/mobile/Applications/24968027-8B41-4B3B-937F-B9624F9661CB/MODULESTEST.app/buildresources/testbundles/bundle_one.bundle//activities/content_specifications.pdf
2012-10-16 14:50:10.038 MODULESTEST[5170:170b] Warning: __45-[PSPDFCache cacheDocument:startAtPage:size:]_block_invoke_0/1015 Document has zero pages. Not caching.

I've also used iExplorer3 and the file is present in the app.


Solution

  • I'm the developer of PSPDFKit.

    The issue here is that you need to initialize your NSURL with fileURLWithPath instead of URLWithString. (Later one CFURLCreateDataAndPropertiesFromResource fails with an undocumented error code that most likely means that it just doesn't support Web-URLs)