我有一个100页的PDF文档,我的应用程序打开。在我的文档中,我添加了各种文本字段,允许用户添加注释。我尝试过各种方法将文本保存在文本框中,以允许用户返回tp编辑/标记文档,但我没有运气。如何将PDFAnotoation TextBox中的文本保存为带注释的字符串,以允许用户在编辑时拾取其停止的位置?
这是我的原作:
var textFieldMultiline21 = PDFAnnotation()
let textFieldMultilineBounds21 = CGRect(x: 27, y: 58+2, width: 339, height: 508)
textFieldMultiline21 = PDFAnnotation(bounds: textFieldMultilineBounds21, forType: PDFAnnotationSubtype(rawValue: PDFAnnotationSubtype.widget.rawValue), withProperties: nil)
textFieldMultiline21.widgetFieldType = PDFAnnotationWidgetSubtype(rawValue: PDFAnnotationWidgetSubtype.text.rawValue)
textFieldMultiline21.backgroundColor = UIColor.clear
textFieldMultiline21.font = UIFont.systemFont(ofSize: 18)
textFieldMultiline21.isMultiline = true
page.addAnnotation(textFieldMultiline21)在这里,我说尝试在文本框中保存文本:
document.page(at: 21)?.annotations[0].contents = "Sample text"
textFieldMultiline21.caption = "sampletext"发布于 2019-03-04 18:32:48
一个隐藏在眼前的简单答案
阅读文本
pdfAnnotationTextField.value(forAnnotationKey: .widgetValue)返回带有属性的字符串值。
设置文本
pdfAnnotationTextField.setValue("Enter Text", forAnnotationKey: .widgetValue)https://stackoverflow.com/questions/54314650
复制相似问题