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 remove_form_fields property to True.

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

with gv.Viewer("sample.docx") as viewer:

    viewOptions = gvo.PdfViewOptions()
    viewOptions.pdf_optimization_options = gvo.PdfOptimizationOptions()
    viewOptions.pdf_optimization_options.remove_form_fields = True

    viewer.view(viewOptions)

The following image demonstrates the result:

Remove fields

On this page