4

I have a pdf template file with form fields (amount_1, amount_2 etc) I created an XFDF file and am using PDFtk via command line to fill the form and flatten the file.

However, when I run the command below, the new pdf is created but the fields are not filled in.

/usr/bin/pdftk /home/admin/tickets/tickets.pdf fill_form /home/admin/tickets/files/1371711546.xfdf output 1371711546.pdf flatten 

the XFDF looks like this

<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<fields>
<field name="amount_1">
<value>$17.00</value>
</field>
<field name="amount_2">
<value>$17.00</value>
</field>
<field name="amount_3">
<value>$17.00</value>
</field>
<field name="amount_4">
<value>$17.00</value>
</field>
</fields>
<ids original="095b7b1e54742b95f30a987149d65453" modified="1371711546" />
<f href="http://test.selebtom.co.zw/tickets/tickets.pdf" />
</xfdf>
fredmarks
  • 327
  • 5
  • 14
  • What type of PDF Form do you have? Are you sure it is an Acroform? Or is it a XFA Form? – Kevin Brown Jun 21 '13 at 04:37
  • I created the form using Adobe Livecycle. When i view the source of the pdf form, i see a lot of reference to XFA e.g ( – fredmarks Jun 21 '13 at 04:42
  • Then I believe you cannot fill an XFA form with PDFtk. Or see http://www.pdflabs.com/docs/pdftk-man-page/ and look for [drop_xfa]. But if the fields are XFA fields then you need a different tool – Kevin Brown Jun 21 '13 at 04:53
  • You can upload here @ iText website and it will tell you if it is an XFA form and show you the XFA: http://demo.itextsupport.com/xfademo/uploadpdf.jsp – Kevin Brown Jun 21 '13 at 05:00
  • Thanks for the info...apart from adobe professional, hat other tool can create acroforms – fredmarks Jun 21 '13 at 05:00
  • I am not clear as to the question, are you looking for a new tool to create the forms or something to fill the forms now that you have XFA forms? iText and several other applications (other than Adobe) can be used to fill XFA forms (you use a different method than your are using) and (as far as I know) only iText with their product XFAWorker can be used to flatten XFA forms (again, other than Adobe). Many, many products can be used to create Adobe Acroforms like FoxIt for example. – Kevin Brown Jun 21 '13 at 05:06

1 Answers1

2

I know it's been a while, but just in case someone is researching this, here's the way I solve this problem:

First, if you don't mind removing the XFA format from the file, thereby creating a new pdf 'template' to do your form fills with, then simply, remove extra XML data with the following command line:

"pdftk xfa-pdf-form.pdf output acro-pdf-form.pdf drop_xfa"

If this still gives you trouble, start over with the original XFA file and in LiveCylce save the the file as an Adobe Static PDF form. Or using Acrobat X Pro I think you can do this too. Then repeat the step above, by calling the command line to drop_xfa.

You should have a regular Acroform at this point.

From here you will be able to save the ouput file's data as an XFDF or FDF. Then it's business as usual.

Thanks to @enriquein, who pointing me in the right direction.

Aaron
  • 3,068
  • 2
  • 21
  • 44
  • I want get xfa data from form pdf either in php or python. Please refer me some solution. Thanks – Lakhan Jan 17 '17 at 12:09