首页 > 解决方案 > 如何检测使用 PDF KIT iOS 加载的 pdf 的变化

问题描述

我在 iOS 中加载了一个可编辑的 pdf。但无法弄清楚用户是否对该pdf进行了任何更改。

NSData *fileData = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"PdfFormExample" ofType:@"pdf"]];
PDFDocument *pdfDocument = [[PDFDocument alloc] initWithData:fileData];
PDFView *pdfView = [[PDFView alloc] initWithFrame:self.view.frame];
pdfView.document = pdfDocument
[self.view addSubView:pdfView];

提前致谢。

标签: iosobjective-cios11pdfkit

解决方案


您可以使用 PDFKit 来控制和加载 pdf 到 iOS 应用程序。它由苹果提供。因为您必须首先为 PDF 设置委托

PDFDocumentDelegate

  • PDFKit 可以发送不同操作的通知,例如开始写入、结束写入等。因此您可以使用这些方法获取本地通知来确定用户是否开始编写或修改 PDF。为此,您可以使用,

PDFDocumentDidBeginPageWriteNotification PDFDocumentDidEndPageWriteNotification

根据您想要进行更改的时间,上述任何一项。

如果您想要更多参考这里是链接:

PDFKit / PDF 文档


推荐阅读