Extract data from PDF Forms via Python

Extract user data fields from fillable PDF document. Use Aspose.PDF for Python for .NET to modify PDF files programmatically

How to Extract data from PDF Forms using Python for .NET Library

In order to extract PDF Forms (Acroforms) in a PDF file, we’ll use Aspose.PDF for Python via .NET API, which is feature-rich, powerful, and easy-to-use document manipulation API for Python app. You can download its latest version directly from PyPi package manager, search for aspose-pdf and install. You may also use the following command from the console or terminal.

How to Extract AcroForm in PDF using Python


You need Aspose.PDF for .NET to try the code in your environment.

  1. Load PDF in an instance of Document class.
  2. Get values from all fields using Document.Form class.
  3. Analyze names and values if needed.
  4. Load PDF in an instance of Document class
  5. Get values from all fields using Document.Form class

Extract data from PDF Forms - Python

This sample code shows how to Extract data from PDF Forms in PDF using Python

import aspose.pdf as apdf

from os import path

path_infile = path.join(self.data_dir, infile)
form = apdf.facades.Form(path_infile)

form_values = {}

for formField in form.field_names:
    form_values[formField] = form.get_field(formField)

print(form_values)