Extract data from PDF Forms via Java

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

How to Extract data from PDF Forms using Java Library

In order to extract data from PDF Forms (Acroforms), we’ll use Aspose.PDF for Java API which is a feature-rich, powerful and easy to use conversion API for Java platform. You can download its latest version directly from Maven and install it within your Maven-based project by adding the following configurations to the pom.xml.

How to Extract AcroForm in PDF using Java


You need Aspose.PDF for Java 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 - Java

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

    // Open document
    Document pdfDocument = new Document(dataDir + "GetValuesFromAllFields.pdf");

    // Get values from all fields
    foreach (Field formField in pdfDocument.Form)
    {
        // Analyze names and values if need
        Console.WriteLine("Field Name : {0} ", formField.PartialName);
        Console.WriteLine("Value : {0} ", formField.Value);
    }