Link Search Menu Expand Document

Create Custom Template - TEMPLATES-SAMPLES

Document Parser sample in TEMPLATES-SAMPLES demonstrating ‘Create Custom Template’

SampleTemplate.json
{
  "templateName": "My Custom Template",
  "templateVersion": 4,
  "templatePriority": 0,
  "detectionRules": {
    "keywords": [
      "Your Company Name",
      "Invoice No\\.",
      "TOTAL"
    ]
  },
  "objects": [
    {
      "name": "total",
      "objectType": "field",
      "fieldProperties": {
        "fieldType": "macros",
        "expression": "TOTAL{{Spaces}}{{Number}}",
        "dataType": "decimal",
        "pageIndex": 0
      },
      "id": 1634133003620
    },
    {
      "name": "dateIssued",
      "objectType": "field",
      "fieldProperties": {
        "fieldType": "macros",
        "expression": "Invoice Date {{SmartDate}}",
        "dataType": "date",
        "dateFormat": "auto-mdy",
        "pageIndex": 0
      },
      "id": 1634133003621
    },
    {
      "name": "invoiceId",
      "objectType": "field",
      "fieldProperties": {
        "fieldType": "macros",
        "expression": "Invoice No. {{Digits}}",
        "pageIndex": 0
      },
      "id": 1634133003622
    },
    {
      "name": "companyName",
      "objectType": "field",
      "fieldProperties": {
        "fieldType": "static",
        "expression": "Vendor Company",
        "pageIndex": 0
      },
      "id": 1634133003623
    },
    {
      "name": "billTo",
      "objectType": "field",
      "fieldProperties": {
        "fieldType": "rectangle",
        "rectangle": [
          32.25,
          150,
          348,
          70.5
        ],
        "pageIndex": 0
      },
      "id": 1634133003624
    },
    {
      "name": "notes",
      "objectType": "field",
      "fieldProperties": {
        "fieldType": "rectangle",
        "rectangle": [
          32.25,
          227.25,
          531,
          47.25
        ],
        "pageIndex": 0
      },
      "id": 1634133003625
    },
    {
      "name": "table1",
      "objectType": "table",
      "tableProperties": {
        "start": {
          "expression": "Item\\s+Quantity\\s+Price\\s+Total",
          "regex": true
        },
        "end": {
          "expression": "TOTAL",
          "regex": true
        },
        "row": {
          "expression": "^\\s*(?<description>\\w+.*)(?<quantity>\\d+)\\s+(?<unitPrice>\\d+\\.\\d{2})\\s+(?<itemTotal>\\d+\\.\\d{2})\\s*$",
          "regex": true
        }
      },
      "id": 1634133003626
    }
  ]
}

PDF.co Web API: the Web API with a set of tools for documents manipulation, data conversion, data extraction, splitting and merging of documents. Includes image recognition, built-in OCR, barcode generation and barcode decoders to decode bar codes from scans, pictures and pdf.

Get your PDF.co API key here!

Download Source Code (.zip)

return to the previous page explore Document Parser endpoint