How to Extract Data from a PDF Using PDF.co Document Parser

PDF.co Document Parser extracts structured information from PDFs and scanned documents using reusable parsing templates. It is suitable for documents such as invoices, statements, reports, receipts, pay stubs, and forms.

In this tutorial, you will create a Document Parser template and use it to extract fields such as:

  • Vendor name
  • Invoice number
  • Invoice date
  • Total amount
  • Line-item information

Document Parser supports native PDFs, scanned PDFs, and JPG, PNG, and TIFF images. Its visual Template Editor lets you define the information to extract without writing code.

Tip: This tutorial uses a template, making it most suitable for documents that share a consistent or reasonably predictable structure. If you need to process invoices with many unrelated layouts, consider PDF.co’s AI Invoice Parser instead.

Step 1: Open PDF.co Document Parser

Sign in to your PDF.co account.

Open Document Parser from the PDF.co dashboard, and then open the template-management area.

Choose the option to create a new Document Parser template.

Step 2: Load a Sample Document

In the Document Parser Template Editor, load a representative test PDF or image.

Use a sample that has the same general structure as the documents you plan to process. For example, when creating an invoice template, the sample should contain the fields and line-item table you want to extract.

The Template Editor uses this file to preview and test the extraction rules while you build the template.

For the best results, choose a clear document with readable text. If you plan to process scanned documents, use a scan that reflects the typical quality of your production files.

Step 3: Configure the Template

Enter a descriptive name for the template, such as:

Standard Supplier Invoice

If the editor provides document-language or OCR settings, select the language used in the source documents. OCR allows Document Parser to recognize text in scanned PDFs and image files.

A template consists of extraction objects. Each object represents a field, table, or other value that PDF.co should return.

Step 4: Choose an Extraction Method

PDF.co Document Parser offers several ways to locate information.

Field from Rectangle Selection

Use Field from Rectangle Selection when a value always appears in approximately the same position.

This method works well for documents with a fixed layout. Examples include:

  • An invoice number in the upper-right corner
  • A customer number in a fixed header
  • A total displayed in the same area on every document

Field Based on Text Search

Use a text-search field when the location of the value can move but a consistent label identifies it.

For example, you can search for labels such as:

  • Invoice Number
  • Invoice Date
  • Amount Due
  • Account Number

Text-search rules can use built-in macros or regular expressions to identify dates, monetary amounts, numbers, and other patterns.

Automatic Key-Value Extraction

Use an automatic key-value field when the document contains recognizable label-and-value pairs.

For example:

Invoice Number: INV-10025

In this example, Invoice Number is the key and INV-10025 is the value.

Table Extraction

Use a table object when you need to extract repeating rows, such as invoice line items.

Tables can be identified using:

  • A fixed rectangle
  • Text-based start and end markers
  • Automatic table detection

Choose the method that best matches the consistency of your documents.

Step 5: Add a Field Using Rectangle Selection

To follow the original workflow, add a field using Field from Rectangle Selection.

Draw a rectangle around the first value you want to extract. Select the value itself rather than the surrounding section of the page.

Give the field a clear, unique name. For example:

  • vendor_name
  • invoice_number
  • invoice_date
  • total_amount

Avoid spaces and ambiguous names because these field names will be used in the structured output.

Select the appropriate data type when applicable:

  • String for names, identifiers, and general text
  • Integer for whole numbers
  • Decimal for prices, totals, and other decimal values
  • Date for dates

Review the previewed value and confirm that the field returns only the required information.

Step 6: Add the Remaining Fields

Repeat the process for each value you want to extract.

For a typical invoice, you might create the following fields:

  • vendor_name
  • invoice_number
  • invoice_date
  • purchase_order_number
  • subtotal
  • tax
  • total_amount
  • currency

Use rectangle-based fields only when the values remain in consistent positions. If a field moves between documents, use a text-search or key-value extraction rule instead.

Step 7: Add a Line-Item Table

If the document contains a table, add a table extraction object.

For a consistently positioned table, use Table from Rectangle and select the area containing the table.

For tables that move or continue across multiple pages, use a search-based table configuration. Define text that identifies where the table begins and ends, and configure the expected columns.

An invoice table might contain columns such as:

  • description
  • quantity
  • unit_price
  • amount

Use clear column names and assign appropriate data types. For example, quantity can be configured as an integer, while unit price and amount can be configured as decimal values.

If the table spans multiple pages, enable multipage processing when available and test the template with a representative multipage document.

Step 8: Review the Extracted Data

Run the template against the loaded test document.

Review every extracted field and table value. Confirm that:

  • Each field has the correct name.
  • Only the intended value is captured.
  • Dates and numbers use the expected data types.
  • Table rows are divided correctly.
  • Multiline values are handled properly.
  • No required fields are missing.

If a field includes its label—for example, Invoice Number: INV-10025 instead of only INV-10025—adjust the selection or extraction expression so that the output contains only the value.

Test the template with several representative documents before using it in a production workflow. A template that works with one sample may need adjustments to accommodate longer values, shifted fields, additional pages, or changes in scan quality.

Step 9: Save the Template

Once the extracted results are correct, save the template.

Return to the template list and locate the saved template. Note its template ID because you will need this value when using the template through the PDF.co API or an automation integration.

If the source-document layout changes later, return to the Template Editor, update the extraction rules, and test the template again.

Step 10: Use the Template to Process Documents

The saved template can now process other documents with the same general layout.

When using the Document Parser API, provide:

  • A direct URL to the source PDF or image
  • The saved template ID
  • A password if the source PDF is password-protected
  • Any optional processing settings required by the workflow

Document Parser returns structured results containing the extracted fields and tables. The response identifies each object by the name assigned in the template, making the data easier to send to another application.

You can use the extracted information to:

  • Add invoice data to accounting software
  • Populate a spreadsheet or database
  • Update CRM records
  • Route documents based on their contents
  • Validate totals and identifiers
  • Trigger approval or notification workflows

The same template can also be used with PDF.co integrations such as Zapier, Make, n8n, and Microsoft Power Automate.

Step 11: null

You have created and tested a PDF.co Document Parser template that extracts structured fields and tables from a PDF or scanned document.

You learned how to select the appropriate extraction method, define clearly named fields, extract line-item tables, review the structured output, and save the finished template for repeated use.

Carefully test the template with multiple representative documents before using it in production. If the documents have highly variable layouts—particularly invoices from many unrelated suppliers—an AI-based parser may be more appropriate than a fixed template.

Related Tutorials

See Related Tutorials