ios – PDFKit交换注释内容

ios – PDFKit交换注释内容,第1张

概述可以在PDFKit中更改FreeText注释的文本(即内容)而不删除注释/构建新注释吗? 在PDFView中查看时,以下代码段不会更改注释的内容: let url = Bundle.main.url(forResource: "Test", withExtension: "pdf")!let document = PDFDocument(url: url)!for index in 0..< 可以在pdfKit中更改FreeText注释的文本(即内容)而不删除注释/构建新注释吗?

在pdfVIEw中查看时,以下代码段不会更改注释的内容:

let url = Bundle.main.url(forResource: "Test",withExtension: "pdf")!let document = pdfdocument(url: url)!for index in 0..<document.pageCount {    let page: pdfpage = document.page(at: index)!    let annotations = page.annotations    for annotation in annotations {        annotation.contents = "[REPLACED]"    }}mainpdfVIEw.document = document

这有效 – 但需要替换注释(因此必须复制注释的所有其他细节):

let url = Bundle.main.url(forResource: "Test",withExtension: "pdf")!let document = pdfdocument(url: url)!for index in 0..<document.pageCount {    let page: pdfpage = document.page(at: index)!    let annotations = page.annotations    for annotation in annotations {        print(annotation)        page.removeAnnotation(annotation)        let replacement = pdfAnnotation(bounds: annotation.bounds,forType: .freeText,withPropertIEs: nil)        replacement.contents = "[REPLACED]"        page.addAnnotation(replacement)    }}mainpdfVIEw.document = document

注意:添加/删除相同的注释也没有用.

解决方法 您是否尝试在更新注释文本后调用pdfVIEw.annotationsChanged(on:pdfpage)? 总结

以上是内存溢出为你收集整理的ios – PDFKit交换注释内容全部内容,希望文章能够帮你解决ios – PDFKit交换注释内容所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/web/1099215.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存