我想使用用户在我的应用程序中输入的信息在 PDF 文件中填写表格。使用 PDFKit 我正在使用以下代码,该代码在我在文本字段中提交数据后执行:
for index in 0..<pdfDocument.pageCount{
if let page = pdfDocument.page(at: index){
let annotations = page.annotations
for annotation in annotations{
if annotation.fieldName == "Candidate name"{
annotation.setValue(nameField.text ?? "", forAnnotationKey: .widgetValue)
page.removeAnnotation(annotation)
page.addAnnotation(annotation)
}
此代码正在执行其工作,但此注释的内容仅在 PDF 本身中选择注释时可见。否则似乎是空的。
我读了一些关于“NeedAppearances”设置的内容,但我在 PDFKit 中找不到它。