2

I have a document template in Word .doc format. The Word document contains Merge fields that needs to be populated dynamically.

I need to convert the Word document to a PDF with form fields. This PDF can then be populated from our Java application quite easily with iText.

The problem I am experiencing is when I try to convert the Word document to PDF. I want the mail merge fields converted to to form fields but none of the tools I have tried seem to do that.

I have tried:

  • Microsoft Office 2007 save as PDF (Only creates a PDF as text, no form fields)
  • PDFCreator (Also just text)
  • Docx4j (I saved the doc as docx and then converted to xml) which uses Apache FOP AFAIK (Also just text, it displays the Merge fields as MERGEFIELD "Surname" while the others display <<Surname>> as it appears in the Doc)
  • I tried opening the PDFs generated in Scribus but each I just get an error that it is not in an acceptable format

Does anyone know of a tool or a Java library available that can do what I need (preferably free)?

Wilhelm Kleu
  • 10,821
  • 4
  • 36
  • 48
  • If FOP supports PDF fields, then docx4j could easily be extended to meet your requirement. Does FOP support PDF fields? Based on http://www.mail-archive.com/fop-dev@xml.apache.org/msg06191.html it seems you may need to create an extension following http://xmlgraphics.apache.org/fop/trunk/extensions.html – JasonPlutext Sep 10 '10 at 00:22
  • FOP again:- see most recently http://old.nabble.com/AcroForm-extension-td28515733.html – JasonPlutext Sep 10 '10 at 00:31
  • If you are just doing a 1-off conversion of the Word doc to PDF, why does it have to be done in Java? Have you considered populating the Word doc using custom XML binding (a newer MS technology, which docx4j at least supports), and then converting to PDF? – JasonPlutext Sep 10 '10 at 00:36

0 Answers0