Form Flattening
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.
Form Field Flattening
Flattening an entire PDF document is very simple using the FormFlatteningOptions object. The following example demonstrates how to flatten all the form fields within a PDF:
// Create a merge document with your PDF containing form fields
MergeDocument document = new MergeDocument(@"C:\AcroForm.pdf");
//Set FormFlattening property of the document
document.FormFlattening = FormFlatteningOptions.Default;
// Save the document
document.Draw(@"C:\AcroForm_Flattened.pdf");
' Create a merge document with your PDF containing form fields
Dim document As MergeDocument = New MergeDocument("C:\AcroForm.pdf")
'Set FormFlattening property of the document
document.FormFlattening = FormFlatteningOptions.Default
'Save the document
document.Draw("C:\AcroForm_Flattened.pdf")
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:
FormFlatteningOptions flatteningOptions = new FormFlatteningOptions();
flatteningOptions.DigitalSignatures = SignatureFieldFlatteningOptions.Retain;
Dim flatteningOptions As FormFlatteningOptions = New FormFlatteningOptions()
flatteningOptions.DigitalSignatures = SignatureFieldFlatteningOptions.Retain