Flatten PDF form content on Server/Desktop

To flatten form fields in a PDF document.

1PDFDoc doc = new PDFDoc(filename);
2
3// flatten only form fields
4doc.FlattenAnnotations(true);

PDF interactive forms (AcroForms)
Full sample code which illustrates some basic PDFNet capabilities related to interactive forms (also known as AcroForms) and annotation flattening.

About form flattening

Form flattening refers to the operation that changes active form fields into a static area that is part of the PDF document, just like other text and images in the document. A completely flattened PDF form does not have any widget annotations or interactive fields.

Using the Field.Flatten()or Page.FlattenField() methods, it is possible to merge individual field appearances with the page content. Apryse SDK also allows you to flatten all forms in the document in a single function call, with PDFDoc.FlattenAnnotations(true). (The true argument instructs Apryse SDK to only flatten fields; were this method passed false, or no argument, it would flatten all annotations as well as all fields.)

Note that it is not possible to undo the Field.Flatten() operation. An alternative approach, one that can be programmatically reversed, would be to set the field as read only using the Field.SetFlag(Field.e_read_only, true) method.

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales