Flattening the form fields of a PDF is the process that will take the values of the form fields, add them to the actual PDF stream and then remove all of the form field structures from the document. The advantages of flattening form fields are that you achieve a PDF that is simpler and smaller as well as a PDF in which the field values not as easily edited.
Document Level Flattening
The following example demonstrates how to flatten all the form fields within a PDF.
MergeDocument document = new MergeDocument(pdfFilePath); document.Form.Output = FormOutput.Flatten; document.Draw(pdfFilePath);
Dim document As MergeDocument = New MergeDocument(pdfFilePath) document.Form.Output = FormOutput.Flatten document.Draw(pdfFilePath)
Field Level Flattening
The following example demonstrates how to flatten individual form field within a PDF.
MergeDocument document = new MergeDocument(pdfFilePath); document.Form.Fields.Output = FormFieldOoutput.Flatten; document.Draw(pdfFilePath);
Dim document As MergeDocument = New MergeDocument(pdfFilePath) document.Form.Fields(0).Output = FormFieldOutput.Flatten document.Draw(pdfFilePath);
Preserving Digital Signatures During Flattening
By default, Digital Signatures will be flattened along with all the other form fields in the PDF (as shown above). If you wish to retain the Digital Signatures during the form field flattening then you can use the DigitalSignatures property of the FormFlatteningOptions. Adding the following line to the above example would retain all the Digital Signatures:
document.Form.SignatureFieldsOutput = FormFieldOutput.Retain;
document.Form.SignatureFieldsOutput = FormFieldOutput.Retain