Cod*_*cil 4 annotations pdfkit ios swift
在我的应用程序中,我有一个基于用户输入的PDF表单。我在PDF表单中强制输入该值。我ILPDFKit在我的应用程序中使用了pod来执行此操作(swift 3,但是由于PDFKit在iOS 11中已经存在,所以我想知道使用PDFKit是否可以实现)。我使用的代码ILPDFKit是:
// set the pdf form as ILPDFDocument
let document = ILPDFDocument(resource:"ExamplePDFfrom")
// Manually set a form value for field name (created in adobe acrobat)
document.forms.setValue("David", forFormWithName: "FirstName")
Run Code Online (Sandbox Code Playgroud)
更新的答案
@objc func pdfPageChanged() {
for index in 0..<doc!.pageCount{
if let page = doc?.page(at: index){
let annotations = page.annotations
for annotation in annotations{
print("Annotation Name :: \(annotation.fieldName ?? "")")
if annotation.fieldName == "firstName"{
annotation.setValue("David", forAnnotationKey: .widgetValue)
page.removeAnnotation(annotation)
page.addAnnotation(annotation)
}else if annotation.fieldName == "checkBox"{
annotation.buttonWidgetState = .onState
page.removeAnnotation(annotation)
page.addAnnotation(annotation)
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
doc是PDFDocument的对象
| 归档时间: |
|
| 查看次数: |
2431 次 |
| 最近记录: |