0

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.

Sven Cozijn
  • 119
  • 14

2 Answers2

1

This is a problem with the PDF form when filled using iOS, if you have adobe acrobat, change the font size of all form field to a new font size and then try again

Codicil
  • 196
  • 3
  • 15
0

This issue happens only in Simulator. Try running it on an actual device and it should work fine.

shahil
  • 941
  • 9
  • 20