Remove form fields

On this page

If the output PDF file contains form fields, you can flatten them to reduce the file size.

To remove form fields, set the RemoveFormFields property to true.

The following code snippet shows how to flatten form fields in the file:

using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...

using (var viewer = new Viewer("sample.docx"))
{
    PdfViewOptions viewOptions = new PdfViewOptions();
    viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions
    {
        RemoveFormFields = true
    };
     
    viewer.View(viewOptions);
}
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...

Module Program
    Sub Main(args As String())
        Using viewer = New Viewer("sample.docx")
            Dim viewOptions As PdfViewOptions = New PdfViewOptions()
            viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions With {
                .RemoveFormFields = True
                }

            viewer.View(viewOptions)
        End Using
    End Sub
End Module

The following image demonstrates the result:

Remove fields

On this page