I need to take an existing pdf file and programmatically fill in a list of form fields with text and then save the pdf without ever displaying it to the user.
For instance, if the pdf file contains fields named "LastName", and "FirstName" I would like to set the value of "FirstName" to "Louis" and then save the file.
I've been searching for a long time and can't find any guidance on even where to start since the iOS documentation (and most of the questions on here) seem geared towards displaying or creating pdf content instead of modifying it.
EDIT:
My main question is: Is it possible to open a pdf stream (I know how to do this) and copy each existing pdf dictionary item into a new pdf? I have not been able to find a way to write the dictionary items to a pdf.
You can also use a browser to fill out and sign PDF forms on your iPhone. Simply go to the Adobe Acrobat online fill and sign tool, upload the PDF document you want to fill and sign, and use the toolbar to fill in the form fields or add your signature.
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.
Open a PDF document in Acrobat. Click the “Fill & Sign” tool in the right pane. Fill out your form: Complete form filling by clicking a text field and typing or adding a text box.
I doubt that kind of functionality will ever be in the iOS frameworks. The reason most of the related info you can find "seem[s] geared towards displaying or creating pdf content instead of modifying it" is because that's what the vast majority of use cases will want or need for PDF functionality.
You'll need to find a 3rd party library that can open up PDFs, fill out the AcroForm fields, and then stamp out a PDF. I use iText on Java (there is also iTextSharp for C#) but I don't know of anything for Objective-C.
Once you find that library, you'll need to integrate it into your project. There are undoubtedly several related questions/answers here on SO for whatever version of the SDK you're using.
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