I’ve searched the forum but nowhere does anyone seem to have created any classes or plugin dedicated to just filling out PDF forms. There are a number of folks that have created classes for creating PDFs from scratch but the references to form filling are thin to non existent or I suck at searching. I know that I can purchase MBS DynaPDF to do this but I’m not looking for a PDF Swiss army knife. I just want a solution that simple to use, efficient and low cost or open source that is purpose built to fill and save PDF forms. I’m looking for suggestions and or recommendations. I’m OK with a shell app that uses open source libraries if that is the only option but I’d rater use native Xojo Classes or a Xojo plugin.
In the MBS examples folder, look in DynaPDF/acroform for what I believe is an example of how to do form fill using DynaPDF.
Thanks Bob. I’ve already reviewed those sample projects and I mentioned in my original post that I’m looking for a purpose built tool that doesn’t cost $199 as an alternative to DynaPDF. I have licenses for other MBS plugins but I do not need or want the functions DynaPDF includes.
I’m not aware of any purpose built tool to do this.
I dont know of any free / low cost PDF libraries that allow you to read a PDF and fill it
I’ve poked around a lot for various free libs for other purposes & there are ones that create PDF’s that are free / inexpensive - but none do filling that I have found
Acrobat on Windows MIGHT be controllable enough to do it but I dont have experience with that
I just played with a fillable PDF, saved it, and looked with an Hex editor : text is saved in ASCII and can be modified rather easily.
but be careful. the PDF format is sometimes very forgiving, and other times not so much. depending on exactly what text you replace, and what you replace it with, you may alter the internal object pointer dictionary to the point where the document becomes corrupt and unreadable. Also, depending on the source of the original PDF, it may contain “zipped” blocks that will NOT be normal ASCII characters…
The inside of a PDF may look like a text file but its not. Reading a PDF file is more like reading a binary file.
What type of PDFs are you trying to fill and save? Can you share and example?
OK. I just filled a form with token words, saved it, then located these words with a Hex editor, modified them, saved, and the result shows the modified text. No more, no less. Obviously for that particular fillable PDF the text is not encrypted and the PDF is still readable. Now since the OP does not want a commercial plugin and obviously no open source way has been located, he will have to DIY.
If it were me, I’ll go DynaPDF…
I use PDFtk for many PDF functions at work. https://www.pdflabs.com/tools/pdftk-server/
Of course you may want to lookup documentation on FDF files.
[quote=262703:@Michel Bujardet]OK. I just filled a form with token words, saved it, then located these words with a Hex editor, modified them, saved, and the result shows the modified text. No more, no less. Obviously for that particular fillable PDF the text is not encrypted and the PDF is still readable. Now since the OP does not want a commercial plugin and obviously no open source way has been located, he will have to DIY.
If it were me, I’ll go DynaPDF…[/quote]
You might want to try opening you modified PDF in Acrobat or Adobe reader. I’m pretty sure and error will be raised.
A PDF file is made up of one of more sections, each section contains pointers to one or more other sections, including size, type of encoding, type of data (text vs images etc). the last section is a XREF table, which contains one entry for each section, its offset from the beginning of the document, and its length. Altering the contents of the file, can cause one or more of these values to become invalid and therefore unreadable. This is NOT always the case, for example if you replace clear text on a one to one character basis, the pointers don’t move. but if you insert or delete text they do. Images are always stored in a compressed format (of which PDF supports multiple types). Text is “usually” also stored compressed, but not always. Most programs that allow you to “fill in a form”, probably disassemble the PDF, insert the new data, and reassemble the PDF again, recalculating all the pointers and references.
I know for a fact, that just telling Adobe to “save” a PDF that you had not altered, usually results in the internal sections being rearranged, and reindexed.
I spent over a year reverese engineering the PDF format, so trust me when I say I have a lot of experience with how its all put together
Well ; Acrobat Reader did not complain. Once again, I just played. Not planning to do more.
Well, from the responses it sounds like my best option seems to be DynaPDF Starter since I don’t want to reinvent the wheel.
I did this in the past with OLE calls to Acrobat, Adobe calls this Interapplication Communication. You can control Acrobat to an amazing level. You can control everything in the UI.
Look at this document with plenty of examples in VB: http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/iac_developer_guide.pdf
A very good source for programmers is PDF Planet: http://www.planetpdf.com/
Some things I managed:
- load a bunch of PDF’s in background
- search the PDF’s for keywords
- extract found text to Word
- fill in user forms with database info
- watermark PDF’s
- combine PDF’s
- Render and control a PDF in your own application
I looked up your question on PDF Planet and this source came up (VB):
Dim bok As Long Dim acroexchapp As Acrobat.CAcroApp Dim acroexchavdoc As Acrobat.CAcroAVDoc Dim aformaut As AFORMAUTLib.AFormApp Dim j As Integer Set acroexchapp = CreateObject("Acroexch.app") Set acroexchavdoc = CreateObject("Acroexch.avdoc") bok = acroexchavdoc.Open(Path) Dim Fld As AFORMAUTLib.Field Dim Flds As AFORMAUTLib.Fields If (bok) Then Set aformaut = CreateObject("AFormAut.App") Set Flds = aformaut.Fields End If For each fld in Flds Set Fld = Flds(field) Fld.Value = value Next
You can do the same with Applescript on the Mac, but be aware that this requires Acrobat; I don’t believe you can control Reader using applescript on Mac or OLE on Windows.
Another way to fill out a form is to create an .fdf file, and import that into the form. But, that also cannot be done through Reader iirc.
I can report that you can do that with DynaPDF Lite and of course I would be happy to offer you a license.
In general I would not recommend to change a byte on a PDF without reading the PDF specs for details on what you do.
Yeah I’m trying to avoid putting an Acrobat pro license on a Web server. I’d prefer the form filling to occur in the Xojo web app and let the user download the completed form. So far DynaPDF still sounds like the best option. I wish Christian had a dedicated form filler plugin at a lower cost though. I wonder ow many developers using Xojo to develop web apps could use a $49.00 PDF form filling plugin?
I am not often asked for form filling alone.