In my swift application there is PDF form field which with all the fields name defined, I want to fill these fields programmatically, however watching the WWDC presentation, PDFKit first draw a frame around the field, meaning creating form field first than setting the vale as
textField.widgetStringVale = “WWDC 2017”
My questions are
1) is it possible to fill the PDF form with fields already created in adobe acrobat in swift programmatically instead of creating first using PDFKit
2) if not for 1) how to determine the absolute frame size for fields as there are many field so I don’t want to trial and error
If you've ever had to edit PDF form and fill out fields by hand, it can soon turn into a real pain. A PDF file isn't plain text and requires specific software to read (and edit) them. One way to fill out PDF form fields in an automated script is to use the . NET Framework.
Save and download the PDF file. Click the green button Save & Download in the toolbar on the left side of the screen to save the PDF form to the device. "When you are filling out the file, click the blue button Save to save your operation in case of losing. "
Yes, you can use PDFKit to programmatically fill a PDF form:
import UIKit
import PDFKit
let pdfURL = ...
let document = PDFDocument(url: pdfURL!)
let page1 = document!.page(at: 0)
let field = page1?.annotations.filter({ $0.fieldName! == "ConferenceName" })
field?[0].widgetStringValue = "WWDC 2017"
let saveURL = ...
document!.write(to: saveURL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With