首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PDFDocument中的PDFKIT iOS 11,保存注解页面

PDFDocument中的PDFKIT iOS 11,保存注解页面
EN

Stack Overflow用户
提问于 2018-03-07 04:34:01
回答 1查看 1K关注 0票数 2

我有一个PDF页面,例如在PDF页面0。我在页面中更改并添加了一些内容。现在我想保存在PDFDocument中。

这是我的代码,这是我的pdf文档:

代码语言:javascript
复制
var pdfDocument: PDFDocument?
pdfView.annotationsChanged(on: (pdfView.currentPage)!)

在这项工作后,pdf在加载更改,但在重新加载后,我有pdf没有编辑。

我知道我可以像pdfDocument?.write(to:)一样保存,但如果可能的话,我想替换一个页面,而不是所有的pdfDoucment。如果不是,我想保存所有页面与新的更改,如新的pdf。

也许我会用这个,但是怎么用呢?

代码语言:javascript
复制
pdfDocument?.write(toFile: String, withOptions: [PDFDocumentWriteOption : Any]?)
EN

回答 1

Stack Overflow用户

发布于 2019-01-16 05:05:19

尝试这段代码来保存pdf内容。我假设你已经加载了PDFDocument

代码语言:javascript
复制
NSString *path = @"Name.pdf";
NSString *docsFolder = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
NSString *newPath = [docsFolder stringByAppendingPathComponent:path];

NSData * content = pdfDocument.dataRepresentation;        
[content writeToFile:newPath atomically:YES];
NSURL *newURL = [NSURL fileURLWithPath:newPath];
pdfdocument = [[PDFDocument alloc] initWithURL:newURL];
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49139509

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档