Skip to main content
.NET Framework 4.5.2+

PdfDocumentProcessor.FlattenFormField(String) Method

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

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v22.2.dll

Declaration

public bool FlattenFormField(
    string name
)

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.

Example

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.

View Example

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the FlattenFormField(String) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also