Removing Form Fields

Form fields can either be removed one at a time or all at once. For flattening form fields (preserving the data but removing the form fields structure) please see the Form Flattening topic.

Removing an Individual Form Field

Removing a form field one at a time is done by setting the field Output property to the FormFieldOutput.Remove.

The following example demonstrates how to remove an individual form field using Form Field's Output property:

MergeDocument document = new MergeDocument(pdfFilePath);
document.Form.Fields[0].Output = FormFieldOutput.Remove;
document.Draw(pdfFilePath);        
Dim MyMergeDocument As MergeDocument = New MergeDocument(pdfFilePath)
MyMergeDocument.Form.Fields(0).Output = FormFieldOutput.Remove
MyMergeDocument.Draw(pdfFilePath)

Removing All Form Fields

If it is known, prior to the merging of a PDF document, that all form fields need to be removed, then the form fields should be removed using the MergeOptions method.

The following example leaves out all form fields when the PDF is merged in:

MergeOptions mergeOptions = new MergeOptions();
mergeOptions.FormFields = false;
MergeDocument document = new MergeDocument(pdfFilePath, mergeOptions );
document.Draw(pdfFilePath);        
Dim mergeOptions As MergeOptions = New MergeOptions()
mergeOptions.FormFields = False
Dim document As New MergeDocument(pdfFilePath, mergeOptions)
document.Draw(pdfFilePath)  

Alternatively, if the form fields are left in the MergeDocument, it can be specified at that the form fields be left off the final output of the PDF by using the Form's Output property.

The following example demonstrates how to remove all the form fields using Form's Output property:

MergeDocument document = new MergeDocument(pdfFilePath);
document.Form.Output = FormOutput.Remove;
document.Draw(pdfFilePath);        
Dim MyMergeDocument As MergeDocument = New MergeDocument(pdfFilePath)
MyMergeDocument.Form.Output = FormOutput.Remove
MyMergeDocument.Draw(pdfFilePath)

In this topic