I'm working with annotations in pdf file. The problem is that text filled in annotation's text field is only visible while editing. As soon as I stop editing this text field, text disappears. I'm filling annotations this way:
for index in 0..<document.pageCount {
if let page = document.page(at: index) {
let annotations = page.annotations
for annotation in annotations {
if annotation.fieldName == key {
annotation.setValue(value, forAnnotationKey: .widgetValue)
page.removeAnnotation(annotation)
page.addAnnotation(annotation)
}
}
}
}
It works only in some documents. I even tried creating new PDF file and then adding forms to it, but the same thing again.