Removing Form Fields
Form fields can be removed individually or all at once. Examples of both are presented below.
Removing an Individual Form Field
A MergeDocument has a Form property, which has a Fields property. The Fields property is a FormFieldsList that contains the individual form fields. The FormField class has an Output property that accepts a FormFieldOutput enumeration. Remove individual fields by setting the field's FormFieldOutput enumeration's value to FormFieldOutput.Remove. Selecting the Remove option removes the form field.
Enumeration | Value | Description |
---|---|---|
FormFieldOutput.Flatten | 0 | The field will be flattened. |
FormFieldOutput.Inherit | 3 | Field's output will depend on the document's form level output settings. |
FormFieldOutput.Remove | 1 | The field will be removed. |
FormFieldOutput.Retain | 2 | The field will be retained. |
The following example demonstrates how to remove a form field.
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
Remove all a form's fields by using the MergeOptions class's FormFields property or by a Form class's Output property.
MergeOptions.FormFields
Use the MergeOptions class to remove all a form's fields by setting the FormFields property to false (the default value is true). The following example omits all form fields.
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)
FormOutput.Remove
If form fields are not removed by the MergeDocument instance, the fields can still be omitted in the final output of the PDF by using the Form class's Output property (FormOutput enumeration).
FormOutput Fields
Enumeration | Value | Description |
---|---|---|
FormOutput.Flatten | 0 | Form fields will be flattened. |
FormOutput.Remove | 1 | Form fields will be removed. |
FormOutput.Retain | 2 | Form fields will be retained. |
The following example demonstrates how to remove all form fields using the 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)