Home > Net >  Flattening a form using iText7
Flattening a form using iText7

Time:06-15

I am facing an issue in flattening the fields of a PDF document using iText7. The issue I am facing is when the fields on a signed PDF are flattened, the signature becomes invalid. I am using PdfAcroForm.FlattenFields() method. Prior calling to the said method, I specify that only the form fields need to be flattened by using PdfAcroForm.PartiallyFlattenFields() method. Could anyone suggest a solution in which I can flatten the fields on already signed document.

CodePudding user response:

I have worked on the said issue and identified a workaround for field flattening on a signed document. There is an issue with PdfSigner.SetFieldLockDict that even though it locks the form in Adobe and does not allow to change/update form fields value but the form is still editable in browsers like Microsoft Edge. The solution I found against this is to make all fields in PDF ReadOnly. By using this approach with PDF having existing signatures, fields are not editable in browsers neither the signature validity is affected. This solution can be implemented to fit different scenarios and may not be suitable under conditions like PDF having a certified policy of form filling and annotations. Cheers!

CodePudding user response:

Flattening form fields produces an update at the page content level. Even when you flatten in append mode (i.e. by appending data to the end of the file that's not covered by the prior signatures), any PDF signature validator worth its salt will reject changes of that type.

Locking form fields in multi-signature workflows can only be done (semi-)reasonably using field locks/FieldMDP. See 12.8.2.4 in ISO 32000-2:2020, and also Table 236. The corresponding clause numbers in ISO 32000-1:2008 are 12.8.2.4 and 12.7.4.5.

Beware: validator behaviour for enforcing FieldMDP is not standardised, so the semantics aren't guaranteed to be identical across vendors.

  • Related