ios - 未保存 PDF 注释

标签 ios arrays annotations pspdfkit

我对 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/

相关文章:

ios - 枚举未添加到 Realm 类

php - PHP 5.3 和 5.4 中访问数组的差异或某些配置不匹配?

Java接口(interface)中的注解值

java - 如何用Ant编译注解处理器?

java - 无法访问带注释的 Spring 服务

ios - 出现键盘时如何使键盘以外的其他界面不可用?

ios - HKWorkoutSession : Not getting Heart Rate when screen is turned off in watchOS 2

java - 在Java中,数组相对于Arraylist有什么优势?

c - 用 int 乘以并添加到 C 中的 int 数组的最快方法?

ios - 在 Swift 中带有 ttf 文件的字形