8 years ago, when dropping XFA was introduced in #1008422: pdftk: Need to drop XML Forms Architecture (XFA) data from filled PDFs, flattening wasn't optional in pdftk.
Later, some 5 years ago, flattening became optional in #920766: Allow non-flattening option. XFA forms however remain to be always removed in pdftk, no matter whether the file is flattened or not.

FillPDF LocalServer, on the other hand, removes XFA forms only when flattening. This seems to be the correct approach. Finally, who wants the populated PDF to be fillable, will expect XFA forms to be kept as well.

At least pdftk and FillPDF LocalServer should produce the same results. While both approaches might be seen as having some merit, the inconsistency makes this a bug.

We just need to take into account what @wizonesolutions initially raised in #1008422: pdftk: Need to drop XML Forms Architecture (XFA) data from filled PDFs:

Currently, when pdftk fills PDF fields in LiveCycle-created PDF forms, it may leave behind what is called XML Forms Architecture data.
In short, this makes the PDF behave incorrectly in Adobe Reader - generally, it will not be flattened, and the fields will never be filled in correctly.
pdftk can drop XFA data, so this needs to be done for the pdftk fill method to ensure module functionality.

Note that this however describes a situation where the PDF is flattened (finally that was non-optional back then), but the XFA not removed.

Comments

Pancho created an issue. See original summary.

pancho’s picture

Assigned: Unassigned » wizonesolutions
Status: Active » Needs review
Related issues: +#3039828: [PP-1] Detect whether a PDF template contains XFA forms
StatusFileSize
new909 bytes

Here's a patch.

For proper testing, we need to be able to #3039828: [PP-1] Detect whether a PDF template contains XFA forms, though.

pancho’s picture

This is what the PDFTK manual says:

If your input PDF is a form created using Acrobat 7 or Adobe Designer, then it probably has XFA data. Filling such a form using pdftk yields a PDF with data that fails to display in Acrobat 7.

The workaround solution is to remove the form’s XFA data, either before you fill the form using pdftk or at the time you fill the form. Using this option causes pdftk to omit the XFA data from the output PDF form.

I can’t really imagine what is meant with “fails to display”. And does the problem only occur if populated by pdftk? We might have to try out Acrobat 7 to see how it actually looks like.

wizonesolutions’s picture

Assigned: wizonesolutions » Unassigned

Fine with this as-is. I'm not worried about Acrobat 7, and even then, we're still removing, just when flattening. That's fine.

pancho’s picture

Assigned: Unassigned » wizonesolutions

Sorry, but as-is is the only way that can't be correct, see the OP:

XFA forms however remain to be always removed in pdftk, no matter whether the file is flattened or not.
FillPDF LocalServer, on the other hand, removes XFA forms only when flattening.

IMO, we have two legitimate options here:

  • We may just assume that what is the case for pdftk holds for LocalServer as well. In that case, LocalServer always needs to remove XFA forms.
  • We may investigate why exactly we're removing XFA forms for unflattened PDFs in our pdftk backend, and if the reason doesn't exist (anymore), make it consistent the other way around.
wizonesolutions’s picture

Let me clarify: fine with the patch as-is, which is to drop_xfa when flattening with PDFtk.

pancho’s picture

LOL, okay, sorry, I misunderstood you indeed. :)

pancho’s picture

Assigned: wizonesolutions » Unassigned

I guess I may unassigned you.

wizonesolutions’s picture

Is there a blocker for committing this?

wizonesolutions’s picture

StatusFileSize
new973 bytes

Re-rolled this patch.

wizonesolutions’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.