.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PdfDocumentProcessor.FlattenFormField(String) Method

Flattens a specific form field on an interactive form by its name.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v20.1.dll

Declaration

public bool FlattenFormField(
    string name
)
Public Function FlattenFormField(
    name As String
) As Boolean

Parameters

Name Type Description
name String

A string that is the name of the form field to be flattened.

Returns

Type Description
Boolean

true, if the interactive form field is flattened successfully; false If the document doesn't contain a form field that should be flattened.

Remarks

To obtain a list of interactive field names in a document, call the PdfDocumentProcessor.GetFormFieldNames method which returns a string collection.

Examples

This example shows how to flatten interactive form fields (e.g., text fields, list boxes).

To flatten a whole interactive form, call the PdfDocumentProcessor.FlattenForm method. If the interactive form is flattened successfully, this method returns true. If the document doesn't contain an interactive form that should be flattened, this method returns false.

To flatten a particular form field by its name, call the PdfDocumentProcessor.FlattenFormField method with a field name used as a parameter. This method tries to find the interactive form field in a document using the field name. If this form field is found in the document, then it will be flattened and this method returns true; otherwise, it returns false.

Imports DevExpress.Pdf
Imports System

Namespace FlattenInteractiveForm
    Friend Class Program
        Shared Sub Main(ByVal args() As String)

            Using processor As New PdfDocumentProcessor()

                ' Load a document with an interactive form.
                processor.LoadDocument("..\..\Document.pdf")

                ' Flatten a form field by its name
                If processor.FlattenFormField("Nationality") Then

                    ' Save a document with the flattened form field. 
                    processor.SaveDocument("..\..\Result1.pdf")

                ' Show a message if the form field was not found in a document.
                Else
                    Console.WriteLine("A document does not contain a form field with the specified name to be flattened.")
                End If

                ' Flatten a whole interactive form.
                If processor.FlattenForm() Then

                    ' Save a document with the flattened form. 
                    processor.SaveDocument("..\..\Result2.pdf")

                ' Show a message if the interactive was not found in a document.
                Else
                    Console.WriteLine("A document does not contain an interactive form to be flattened.")
                End If
            End Using
        End Sub
    End Class
End Namespace
See Also