0

I have used this code :

NSURL *documentURL= [NSURL fileURLWithPath:aStrPrintPdfPath isDirectory:NO];
PSPDFDocument *document = [PSPDFDocument documentWithURL:documentURL];

PSPDFViewController *pdfController = [[PSPDFViewController alloc] initWithDocument:document];
pdfController.pageTransition = PSPDFPageTransitionCurl;
pdfController.renderingMode = PSPDFPageRenderingModeFullPageBlocking;
[pdfController setUpdateSettingsForRotationBlock:^(PSPDFViewController *aPDFController, UIInterfaceOrientation toInterfaceOrientation) {
    // conditionally set depending on rotation
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
        aPDFController.pageMode = PSPDFPageModeDouble;
    }  else {
        aPDFController.pageMode = PSPDFPageModeSingle;
    }

}];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:pdfController];
[self presentViewController:navController animated:YES completion:NULL];
pdfController.title = @"";
[pdfController release];
[navController release];

Now problem is it takes around 30 to 50 seconds to give these error : Error: NSError *PSPDFError(NSInteger, NSString *_strong, NSError *_autoreleasing *)/35 Error 210: documentRef is nil; cannot get pageRef for page 1. hanging my UI completetly and then it opens with pdfController with nothing

Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132

2 Answers2

2

this is the main developer of PSPDFKit.

When you get "documentRef is nil; cannot get pageRef" - this means that the PDF source used to create the PSPDFDocument is invalid. Check the isValid property on the document to test this programmatically.

I'm not sure on what version you are, but at least 3.x does not block your UI thread, but simply show an empty view controller that's waiting for you to set a different document.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
steipete
  • 7,581
  • 5
  • 47
  • 81
0

Never used PSPDFViewController before, but from the error you're getting it may be the case that the memory might be managed in the init.

These are completely ballpark suggestions, but just trying to help you out:

try removing your pdfcontroller release or adding an autorelease at the end of your init (this probably won't have an effect if you add the autorelease however)

try creating a @property for your pdfcontroller in your header file and releasing/managing the memory in your viewdidunload method (and maybe even dealloc).
kevinl
  • 4,194
  • 6
  • 37
  • 55