After adding annotation to PDFPage (and rendering it on a screen), there is no way to update its appearance on PDFPage
/PDFView
.
To reproduce the problem:
Create PDFAnnotation and add it to the
PDFPage
:let bounds = CGRect(x: 20.0, y: 20.0, width: 200.0, height: 200.0) let annotation = PDFAnnotation(bounds: b, forType: .widget, withProperties: nil) annotation.widgetFieldType = .text annotation.backgroundColor = .gray annotation.font = .systemFont(ofSize: 18) annotation.widgetStringValue = "Test!" page.addAnnotation(annotation)
After it is presented on a PDFPage, try to edit its bounds/color/background color/string value etc.:
annotation?.setValue("Help! SOS! Mayday!", forAnnotationKey: .widgetValue) annotation?.color = .green annotation?.bounds = CGRect(x: 0.0, y: 0.0, width: 100.0, height: 100.0)
Nothing happens.
I am aware of a trick:
page.removeAnnotation(annotation)
page.addAnnotation(annotation)
but it is rather a workaround, not real solution.
freeText
and editing text is exactly what I need there. – Lanti