3

Consider this PDF form.

I'd like to fill it using pdftk, as in this question, but preserve the ability to open and edit the form fields in Adobe Reader, as well as preserve the Javascript validation.

Consider the following fdf file, which we can put in a file called Fill.fdf.

%FDF-1.2

1 0 obj
<<
/FDF << /Fields 2 0 R>>
>>
endobj
2 0 obj
[<< /T (form1[0]) /V () >>
<< /T (form1[0].#subform[0].P1_Line1_Name[0]) /V (My Name) >>
]
endobj
trailer
<<
/Root 1 0 R

>>
%%EOF

We apply this fdf file to the form using pdftk.

pdftk i-864.pdf fill_form Fill.fdf output Output.pdf

If we then open Output.pdf in Adobe Reader, we get the following error.

This document enabled extended features in Adobe Acrobat Reader. The document has been changed since it was created and use of extended features is no longer available. Please contact the author for the original version of the document.

I presume that pdftk broke Adobe's digital signature when it filled the form, which is what causes the error above.

This answer removes that error, but it removes the Javascript inside the original PDF, breaking some of the validation on fields that is run when the file is opened in Adobe Reader.

pdftk Output.pdf cat output SignatureRemoved.pdf

If we open SignatureRemoved.pdf in Adobe Reader, we can still edit the form fields, but none of the validation on fields (such as constraining which characters are allowed in each field) runs any longer.

Is there a way to either remove the signature without removing the Javascript, or reapply the signature to the result of filling a form with pdftk?


Update: I've also attempted to use qpdf, but it does not remove the signature.

merlin2011
  • 71,677
  • 44
  • 195
  • 329
  • 1
    You have to fill out the form in *append mode*. This results in PDF's with a higher file size because new data is added after the `%%EOF` marker at the end of the file. The advantage however is that the original bytes are left intact, which preserves the validity of the signature. By the way: pdftk is nothing more than an obsolete version of iText compiled to an executable using GCJ. Please use the original iText, not the copy. – Bruno Lowagie Jul 06 '18 at 06:39
  • @BrunoLowagie, I seem to be unable to find an executable comparable to `pdftk` on the iText website. Does such an executable exist, or do I have to write my own front end to the iText library to get comparable CLI functionality to `pdftk`? – merlin2011 Jul 06 '18 at 08:57
  • You won't find `pdftk` on the iText web site because `pdftk` is not endorsed by iText Group. It uses a version of iText [that shouldn't be used in a commercial context](https://developers.itextpdf.com/question/versions-older-than-5). – Bruno Lowagie Jul 06 '18 at 09:36
  • @BrunoLowagie, I'm looking for something with a comparable command line interface, not pdftk specifically. does such a front end exist for the modern version of iText? – merlin2011 Jul 06 '18 at 17:42

0 Answers0