PDF注释未保存

时间:2014-07-30 13:33:49

标签: 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];

我收到了我已添加的相同注释。 如果我在将文档保存到文件后尝试编写此行代码,则会收到空数组。同样在委托方法文档中:didSaveAnnotations:我收到注释的空数组。 我试着saveAnnotationsWithCompletionBlock:,但我也得到了空的注释数组。 显然,屏幕上的文档也不包含任何注释。

请帮帮我。 提前谢谢。

1 个答案:

答案 0 :(得分:1)

您需要指定'选项'

@{kPSPDFProcessorAnnotationTypes : @(PSPDFAnnotationTypeAll)}
generatePDFFromDocument:

中的

相关问题