Quick Start with the Document Parser Template Editor: How to Create a Template

In this tutorial, you will learn how to create a reusable Document Parser template with the PDF.co Online Template Editor. The template will extract individual fields, multiline text, a fixed table, values found through text searches, and predefined static values.

You can follow along using the sample invoice PDF.

Sample Invoice To Create A Document Parser Template
Screenshot of a Sample Invoice for the Document Parser Template

Open the Template Editor

  1. Sign in to your PDF.co account.
  2. Open the Document Parser Template Editor.
  3. Create a new template.
  4. Load the sample invoice or another representative document.

For reliable results, build and test the template with documents that have the same general structure as the files you plan to process.

Open the Template Editor

Extract a One-Line Field

We will begin by extracting the invoice number.

  1. Click Add Object.
  2. Select Field from Rectangle Selection.
  3. Draw the rectangle around the complete invoice number.
  4. Give the object a descriptive name, such as invoiceNumber.
  5. Click Test Object and confirm that only the invoice number is returned.

Resize the rectangle if it captures surrounding labels or unrelated text.

Extract the Invoice Date

Add another Field from Rectangle Selection object and place it over the invoice date.

Configure the object as follows:

  • Name: invoiceDate
  • Data Type: Date
  • Rectangle: Cover the complete date without including nearby text.

Test the object and verify that the date is returned in the expected format.

Extract Multiline Text

The invoice address contains multiple lines but can still be extracted with one rectangle object.

  1. Add another Field from Rectangle Selection object.
  2. Draw the rectangle around the entire address.
  3. Name the object invoiceAddress.
  4. Test the object and confirm that all address lines are included.

The rectangle should be large enough to include the complete address but should not overlap unrelated content.

Extract a Fixed Table

Use a rectangle-based table object when the table remains in approximately the same location and has a consistent structure.

  1. Click Add Object.
  2. Select Table from Rectangle.
  3. Draw a rectangle around the entire table, including all required rows and columns.
  4. Give the object a descriptive name, such as invoiceItems.
  5. Click Test Object.
  6. Review the extracted rows and columns and adjust the rectangle if necessary.

This approach is best suited to a fixed, single-page table. Documents with tables that move or continue across pages may require a search-based or automatically detected table object instead.

Extract Values Using Text Search

A search-based field can locate values even when their positions vary between documents.

Extract the Subtotal

  1. Click Add Object.
  2. Select Field based on Text Search.
  3. Name the object subtotal.
  4. In Expression, enter:SUBTOTAL{{Spaces}}{{Money}}
  5. Enable the expression or regular-expression option required by the editor.
  6. Set Data Type to Decimal or Currency.
  7. Click Test Object and verify that the subtotal is returned.

The {{Spaces}} macro matches one or more spaces, while {{Money}} matches a monetary value.

Extract the Sales Tax

Create another Field based on Text Search object with the following expression:

SALES TAX{{Spaces}}{{Money}}

Name the object salesTax, select the appropriate numeric data type, and test the result.

Extract the Total

Create another search-based field with this expression:

TOTAL DUE BY DATE{{Spaces}}{{Money}}

Name the object totalDue, configure its data type, and test the result.

If an expression does not return the expected value, check the document’s capitalization, spacing, and wording. You can also use case-insensitive matching or adjust the expression as needed.

Add Static Values

A Field with Static Value returns predefined information that does not need to be extracted from the source document.

Add the Currency

  1. Click Add Object.
  2. Select Field with Static Value.
  3. Set the object name to currency.
  4. Enter USD as the value.
  5. Test the object.

Add the Company Name

Add another Field with Static Value object:

  • Name: companyName
  • Value: ACME Inc.

Static values are useful for adding a vendor name, currency, template identifier, document category, or other known information to every extraction result.

Test the Complete Template

After configuring all objects:

  1. Give the template a descriptive name.
  2. Click Run Template to process the sample document.
  3. Review the complete output.
  4. Confirm that every field has a meaningful and unique name.
  5. Verify the values, data types, table rows, and static information.
  6. Correct and retest any object that returns incomplete or incorrect data.

Whenever possible, test the template with several representative documents rather than relying on only one sample.

Save the Template

Once the results are correct, save the template to the PDF.co Document Parser Template Manager. You can also export the template to a file for backup or reuse.

The saved template can then be selected by its template ID when using the PDF.co Document Parser API or supported automation integrations.

You have created a reusable Document Parser template that extracts fixed-position fields, multiline text, table data, search-based monetary values, and static information. You also learned how to test individual objects and validate the complete extraction result before saving the template.

For additional object types, macros, expressions, and advanced table options, see the PDF.co Document Parser Template Creation Guide.

Related Tutorials

See Related Tutorials