I have an issue with PSPDFKit. The problem is the following:
I have an array of annotations. I need to add them to the pdf document.
PSPDFDocument *newDocument = [PSPDFDocument documentWithURL:someURL];
newDocument.delegate = self;
[newDocument addAnnotations:annotations];
[newDocument saveAnnotationsWithError:nil];
NSError *error;
if (![[PSPDFProcessor defaultProcessor] generatePDFFromDocument:newDocument
pageRanges:@[[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, newDocument.pageCount)]]
outputFileURL:someURL
options:nil
progressBlock:nil
error:&error])
{
NSLog(@"%@", error);
}
For testing purposes I add annotations only to the first page. After I have added annotations I can write
NSArray *array = [newDocument annotationsForPage:0 type:PSPDFAnnotationTypeAll];
And I receive same annotations that I've added. If I try to write this line of code after I have saved the document to file, I receive empty array. Also in the delegate method document:didSaveAnnotations: I receive empty array for annotations. I tried to saveAnnotationsWithCompletionBlock:, but I get empty annotations array there as well. Clearly, the document on the screen does not contain any annotations too.
Please, help me out. Thank you in advance.
You need to specify the 'options'
@{kPSPDFProcessorAnnotationTypes : @(PSPDFAnnotationTypeAll)}
in generatePDFFromDocument: