I would like to fill a form in a PDF file using information users entered into my app. Using PDFKit I am using the following code which is executed after I submit the data in a textfield:
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)
}
This code is doing its job, but the content of this annotation is only visible when the annotation is selected in the PDF itself. Otherwise is seems empty.
I read something about the setting 'NeedAppearances', but I can't find it within PDFKit.