Programmatically filling in a pdf with Acroform XS elements

Hi all:
So I had this gig to programmatically fill in pdfs using Java. I downloaded the apache pdfbox jars and thought that I was all set. Was I ever wrong. Nothing worked. If you have a pdf made by AdobeLive, it is in a proprietary XML format that doesn’t respond to all of the online tutorials. You can’t even invoke Node.getName(). The reason is that the proprietary format has javascript embedded in it to validate inputs. The javascript also populates things like Select boxes, checkboxes, highlighting the tabbed input with a red border, etc which are not part of the regular pdf standard.

The biggest problem when programmatically filling out the form, is to find out the Node names. However when you parse for getting elements with the tag xs: element, there is no node name because the element is sometimes 2 or 3 child nodes down. So you can either write a DOM node tree iterator or you can write out the XML in readable format and manually parse the node names. Then you can programmatically fill it in with a custom module.
If anyone needs example code to do this, ping me.
Ken

2 Likes