Flattening PDF form fields and annotations.

Q: We’ve tried using two other PDF libraries and have discovered
problems with each regarding how they handle form fields.

First, I need to be able to programmatically fill-out a form’s fields
and save the document in a way that I can read the document back
(first page only) and import all its elements onto a new page. That
means the form fields must be lost, but their “look” preserved–
including font and size.

When your library “flattens” a PDF does it only make the fields read-
only or does it truly flatten them so that when I read the document
back its Form.Fields.Count = 0?

A: PDFNet SDK can truly flatten form fields and other annotation
types. You can also change read-only flag on the annotation (using
annot.SetFlag(…)), however this is not a typical definition of ‘form

You can flatten individual widget annotations as shown in the last
code sample in InteractiveForms project (http://www.pdftron.com/
pdfnet/samplecode.html#InteractiveForms) or simply call:

doc.FlattenAnnotations(true); // to flatten all forms, but no other annotations

Flattening a form field will remove annotation from the page, but will
not delete form field value (which may be used on other pages or for
other purposes). In case you also want to remove all forms related
data from PDF simply use the following line after the above line: