Prepare Parse Info for Document
What this guide covers
Prepare Parse Info is the dashboard setup that turns a raw PDF into automated PDF data extraction. You define capture keys, draw zones on a sample document, and assign each key an extraction rule using either Regex Expression for stable patterns or JavaScript Expression for conditional logic. Once saved, the same template runs from the REST API, Make, Zapier, Power Automate, and n8n by referring to its TemplateId.
Authenticating Your Setup
Parse template creation happens in the PDF4me developer dashboard. Sign in with your account, then create or copy an API key for the Parse Document API calls that use the template you build here.
Important Facts You Should Not Miss
TemplateId for the template. Always pass TemplateId in production API calls. TemplateName works too but renaming the template breaks any automation referencing it by name.Step 1: Create the parse template
- Open the Parse Document dashboard.
- Click Add and enter a clear template name (for example,
invoiceorvendor-statement). - Click Save to create the empty template.
- Open the template in Edit mode to start configuring capture keys.

Step 2: Upload a sample and configure capture keys
The dashboard renders an uploaded PDF on the right and shows the Parse Info form on the left. Use real production-shaped samples, not synthetic test files, so the capture areas match what you will see in live traffic.
- Click Upload Template File and pick a representative sample (invoice, contract, form).
- Under Keys, click + to add a capture key. Give it a name in camelCase:
invoiceNumber,customerName,totalAmount. - Choose Choose expression type for the key:
Javascript ExpressionorRegex Expression. - Paste the expression body in the field that appears.
- Set Pages to
allto scan every page, or to a specific page number (1,2, etc.) to limit the scope. - Toggle Search Whole Page on when the value is not at a fixed position. With it off, only the drawn capture area is searched.

Parse Document setup screen. Left: Parse Info form with Keys and expression type. Right: uploaded sample PDF. Action buttons run left to right: Upload Template File, Test Parse, Save Changes.
Step 3: Pick the expression type per key
| Expression Type | Best for | Typical use | Complexity |
|---|---|---|---|
| Regex Expression | Fixed text patterns | Invoice number, dates, totals, tax IDs, postal codes | Low |
| JavaScript Expression | Conditional and multi-rule extraction | Document classification, fallback logic, rule orchestration | Medium to High |
Regex Expression patterns (regex pdf parser basics)
Use Regex Expression when the field has a stable, predictable shape. The captured area is scanned for the first match.
INV-\d{6,10}
\d{2}/\d{2}/\d{4}
\$?\d{1,3}(?:,\d{3})*(?:\.\d{2})?
Common key mappings for an invoice:
invoiceNumber→INV-\d{6,10}invoiceDate→\d{2}/\d{2}/\d{4}totalAmount→\$?\d{1,3}(?:,\d{3})*(?:\.\d{2})?
These same patterns also work for the same fields in vendor statements, purchase orders, and shipping documents because invoice numbers, dates, and amounts share the same shape across most business documents.
JavaScript Expression for conditional logic
Use JavaScript Expression when the output depends on the presence or combination of multiple markers in the document. PDF4me passes the extracted text into your function as the variable text. Your function evaluates the text and returns a string that becomes the value for the key.
Example 1: classify by content markers
Distinguishes a Terms and Conditions document from an Order document by checking which marker phrases appear:
function functionFormatTextDate1(text) {
console.log("Hello");
var term = [...text.matchAll(/General Terms and Conditions/gi)];
var order = [...text.matchAll(/your ordernumber/gi)];
if (term.length) {
if (order.length) {
return "Order document";
} else {
return "Terms and Conditions";
}
} else {
return "Not Terms and Conditions";
}
}
return functionFormatTextDate1(text);
Example 2: invoice vs order detection
A short classifier that decides whether the document is an invoice or an order based on the presence of the words invoice and ordernumber:
function functionGetInvoiceOrder(text) {
// You get all PDF text in `text`
var invoice = [...text.matchAll(/invoice/gi)];
var order = [...text.matchAll(/ordernumber/gi)];
if (invoice.length) {
if (order.length) {
return "Order document";
} else {
return "invoice";
}
} else {
return "";
}
}
return functionGetInvoiceOrder(text);
Implementation tip: Wrap your logic in a named function and call it with return functionName(text); at the bottom. The dashboard executes the expression body as a function whose final returned value populates the key.
Step 4: Test Parse and Save Changes
The action buttons at the top of the editor run left to right in the order you use them:
- Upload Template File loads the sample PDF used for drawing capture areas.
- Test Parse runs all keys against the uploaded sample and shows the extracted values inline. Use this to validate each Regex or JavaScript expression before saving.
- Save Changes persists the template and assigns a stable TemplateId (GUID). Copy that GUID for use in API calls and automation platforms.
Iterate on each key until Test Parse returns the expected value for every field. Tighten the capture area if you see neighbour text, or refine the expression if pattern matches are too loose.
Use the template in API or automation calls
Once Save Changes assigns a TemplateId, the same parse template runs anywhere by reference. You do not need to recreate the configuration on each platform.
| Field | Source | Purpose |
|---|---|---|
TemplateId | GUID shown in the template detail panel after saving | Stable identifier for production automation. Always prefer this over TemplateName. |
TemplateName | The name you typed in Step 1 | Alternative for lookup. Renaming the template breaks calls that reference it by name. |
ParseId | A GUID you generate client-side (one per call) | Correlates your request with the parse output, useful for logging and audit trails. |
docName | Source PDF filename | Used for tracking and error messages. |
docContent | Source PDF encoded as Base64 | The file to parse. |
async | false for synchronous, true for polling | Controls response delivery. |
Example REST request body:
{
"docName": "invoice.pdf",
"docContent": "BASE64_ENCODED_PDF_CONTENT",
"TemplateId": "12345678-1234-1234-1234-123456789abc",
"ParseId": "87654321-4321-4321-4321-cba987654321",
"async": false
}
The response contains one field per key you defined in the template. Route that JSON into any downstream node: Google Sheets, Airtable, a database, Excel, or a webhook.
Common workflows
Typical parse-template patternsHow a saved parse template moves from dashboard to production.
- A vendor invoice PDF arrives in a watched email or cloud folder.
- Make, Zapier, Power Automate, or n8n calls Parse Document with your TemplateId.
- The structured JSON output (invoiceNumber, totalAmount, invoiceDate) is appended as a row in Google Sheets or Excel.
- Accounting reviews and approves directly from the spreadsheet.
- A customer uploads a filled PDF form through your portal.
- Your backend calls Parse Document with TemplateId and the Base64 PDF.
- The parsed JSON is mapped into a database INSERT, with one column per template key.
- A confirmation email goes back to the customer using the parsed name and reference number.
- A single watched folder receives mixed documents (invoices, orders, contracts).
- A JavaScript Expression key in the template returns the document type (see Example 2 above).
- Your workflow routes each file to the right downstream system based on the returned type.
- Files identified as invoices continue to Regex-based field extraction in the same template call.
Template configuration best practices
- Draw capture areas slightly larger than the expected value so font or position drift does not push the value out of frame.
- Keep key names consistent in camelCase across templates so downstream mapping in spreadsheets, databases, and webhooks stays predictable.
- Test every key against at least three real samples, including edge cases like missing optional fields, second-page invoices, and OCR-derived text from scanned PDFs.
- Use JavaScript Expression only where Regex cannot express the rule. Keeping logic simple makes the template easier to debug.
- Version your templates by name (
invoice-v1,invoice-v2) when making breaking changes, so production automation can migrate at its own pace. - Run scanned PDFs through OCR first (the PDF4me OCR endpoint) before parsing. Templates extract from the text layer, which scanned PDFs do not have until OCR is applied.