This is a companion discussion topic for the original entry at https://www.raywenderlich.com/2910656-pdfkit-annotations
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/2910656-pdfkit-annotations
Hi Rony,
I have created a PDF form using PDF editor and I am trying to fill programmatically find the below code which I am using.
But it the value is getting updated. I believe I am missing something. Could you please advise?
if let documentURL = Bundle.main.url(forResource: “myPDFDataEntryForm”, withExtension: “pdf”),
let doc = PDFDocument(url: documentURL),
let _ = doc.page(at: 0){
for index in 0…<doc.pageCount{
if let page = doc.page(at: index){
let annotations = page.annotations
for annotation in annotations{
if annotation.fieldName == "txtFirstName"{
annotation.setValue($firstName, forAnnotationKey: .widgetValue)
page.removeAnnotation(annotation)
page.addAnnotation(annotation)
}
}
}
}
@ronyr Can you please help with this when you get a chance? Thank you - much appreciated! :]