我对 PSPDFKit 有疑问。问题如下:
我有一组注释。我需要将它们添加到 pdf 文档中。
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);
}
出于测试目的,我只在第一页上添加了注释。 添加注释后,我可以编写
NSArray *array = [newDocument annotationsForPage:0 type:PSPDFAnnotationTypeAll];
而且我收到了我添加的相同注释。 如果我在将文档保存到文件后尝试编写这行代码,我会收到空数组。同样在委托(delegate)方法 document:didSaveAnnotations: 中,我收到了用于注释的空数组。 我尝试保存 AnnotationsWithCompletionBlock:,但我也在那里得到空的注释数组。 显然,屏幕上的文档也不包含任何注释。
请帮帮我。 提前谢谢你。
最佳答案
您需要指定“选项”
@{kPSPDFProcessorAnnotationTypes : @(PSPDFAnnotationTypeAll)}
在 generatePDFFromDocument:
关于ios - 未保存 PDF 注释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25038239/