1

I am now using pspdfkit for ios and I can now annotate pdf from local directory. The problem is that annotation are saved automatically. I have opened pdf like this. How can I save pdf only when I press save button? I can do custom save button like following codes.

PSPDFDocument *document = [PSPDFDocument documentWithURL:documentURL];
PSPDFViewController *pdfController = [[PSPDFViewController alloc] initWithDocument:document];

pdfController.openInButtonItem.openOptions = PSPDFOpenInOptionsOriginal;
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(backFromDocument)] ;
pdfController.leftBarButtonItems = @[backButton];

pdfController.rightBarButtonItems = @[pdfController.annotationButtonItem, pdfController.searchButtonItem, pdfController.outlineButtonItem, pdfController.viewModeButtonItem];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:pdfController];
[self presentViewController:navController animated:YES completion:NULL];
Khant Thu Linn
  • 5,905
  • 7
  • 52
  • 120

1 Answers1

2

To disable the autosave function call document.annotationSaveMode = PSPDFAnnotationSaveModeDisabled on the PSPDFDocument.

To save an annotation by clicking a specific button you can call saveAnnotationsWithError in PSPDFAnnotationParser.

matthisb
  • 1,108
  • 12
  • 29