我想使用用户在我的应用中输入的信息填写 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 中找不到它。
最佳答案
这是PDF表单使用iOS填写时的问题,如果你有adobe acrobat,请将所有表单域的字体大小更改为新的字体大小,然后重试
关于swift - IOS PDFKit - 注释内容仅在选中时可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57988924/