Flatten PDF Form Fields in C# .NET

Flattening PDF form fields means that you remove form field objects from a document’s internal structure and place their data in the PDF as regular items. This means that form fields are no longer fillable and their data can’t be extracted.

Flattening All Form Fields

To flatten all form fields in a PDF document, use the FlattenFormFields method:

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");
// Flatten all form fields.
gdpicturePDF.FlattenFormFields();
gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    gdpicturePDF.LoadFromFile("C:\temp\source.pdf")
    ' Flatten all form fields.
    gdpicturePDF.FlattenFormFields()
    gdpicturePDF.SaveToFile("C:\temp\output.pdf")
End Using
Used Methods

Related Topics

Flattening Form Fields on a Specified Page

To flatten all form fields on a specific page of a PDF document, use the FlattenFormFields method and specify the page number as its parameter:

using GdPicturePDF gdpicturePDF = new GdPicturePDF();
gdpicturePDF.LoadFromFile(@"C:\temp\source.pdf");
// Flatten form fields on the second page.
gdpicturePDF.FlattenFormFields(2);
gdpicturePDF.SaveToFile(@"C:\temp\output.pdf");
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    gdpicturePDF.LoadFromFile("C:\temp\source.pdf")
    ' Flatten form fields on the second page.
    gdpicturePDF.FlattenFormFields(2)
    gdpicturePDF.SaveToFile("C:\temp\output.pdf")
End Using
Used Methods

Related Topics