FormFlattener Plugin

Overview

The Aspose.Pdf.LowCode.FormFlattener plugin converts interactive PDF form fields into static page content. Use FormFlattenAllFieldsOptions to flatten every field or FormFlattenSelectedFieldsOptions to flatten selected fields.

Flatten all form fields

// For complete examples and data files, visit https://github.com/aspose-pdf/Aspose.PDF-for-.NET
private static void FlattenPdfFormWithPlugin()
{
    // The path to the documents directory
    var dataDir = RunExamples.GetDataDir_AsposePdf_Forms();

    // Create PDF FormFlattener plugin
    var plugin = new Aspose.Pdf.LowCode.FormFlattener();

    // Add input and output files
    var options = new Aspose.Pdf.LowCode.FormFlattenAllFieldsOptions();
    options.AddInput(new Aspose.Pdf.LowCode.FileDataSource(dataDir + "TextField.pdf"));
    options.AddOutput(new Aspose.Pdf.LowCode.FileDataSource(dataDir + "FlattenPdfForm_out.pdf"));

    // Flatten form fields
    var result = plugin.Process(options);

    // Get the path of the saved PDF document
    var outputPath = result.ResultCollection[0].ToFile();
}

Options

Use FormFlattenSelectedFieldsOptions when field selection should be controlled by a public field predicate.