IOS PDFKit - 注释内容仅在选中时可见



我想使用用户输入到我的应用程序中的信息在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中找不到它。

这是使用 iOS 填写时 PDF 表单的问题,如果您有 adobe acrobat,请将所有表单字段的字体大小更改为新字体大小,然后重试

此问题仅在模拟器中发生。尝试在实际设备上运行它,它应该可以正常工作。

最新更新