Link Search Menu Expand Document

Document Parser: Template Creation Guide

Table of Contents:

<h2>What is Document Parser and How It Works?</h2><p>Document Parser is the versatile document parsing engine that helps to do accurate and easy to maintain data extraction data from PDF invoices, statements, reports, paystubs, tables, reciepts. No programming is reqired to create and maintain data extraction templates! Supports both native and scanned PDF files, PNG, JPG, TIFF images and Doc, Docx, PPT files (only in Web API version) as well as English, German, French, Spanish and many other languages. Available as Web API, Zapier and on-premise API server or as direct integration module.</p><p>Template specification version: 3.</p><p>Templates can be written in YAML or JSON formats. A template defines one or more keywords to match the right template to the document and expressions for fields and tables to be extracted. A single template file can contain multiple templates. Templates in YAML file should be separated with --- line. Templates in JSON must be arranged as an array [].</p><p>Sample YAML template showing the main features:</p><pre><div>--- templateVersion: 3 templatePriority: 1 sourceId: ACME Inc. Invoice culture: en-US

detectionRules: keywords: - ACME Inc. - Invoice No - ABN 01 234 567 890

fields: companyName: type: static expression: ACME Inc. invoiceNumber: type: regex expression: ‘Invoice No.: ()’ pageIndex: 0 invoiceDate: type: regex expression: ‘Invoice Date: ()’ dataType: date dateFormat: MM/dd/yyyy billTo: type: rectangle rectangle: - 32.5 - 64.5 - 200 - 100 pageIndex: 0 total: type: regex expression: ‘TOTAL()’ dataType: decimal

tables: - name: table1 start: expression: ‘ItemQuantityPriceTotal’ end: expression: TOTAL row: expression: ’(?<description>)(?<quantity>)(?<unitPrice>)(?<itemTotal>)’ columns: - name: description type: string - name: quantity type: integer - name: unitPrice type: decimal - name: itemTotal type: decimal multipage: true </div></code></pre><h2 id="template-parameters">Template Parameters</h2><h3 id="templatepriority">TemplatePriority</h3><p>Templates are sorted and tried by templatePriority, then alphabetically. 0 - the highest priority, 999999 - the lowest.</p><h3 id="sourceid">SourceId</h3><p>Some name that identifies the design of the document. Passed to the result unchanged.</p><h3 id="culture">Culture</h3><p>Template culture that affects the detection of dates and decimal numbers. For example, if en-US culture is set, the parser will expect dates in month-day-year sequence, and decimal numbers with the dot as the decimal symbol and the comma as the digit grouping symbol. For fr-FR culture, the parser will expect dates in day-month-year sequence, and decimal numbers with the comma as the decimal symbol and the space as the digit grouping symbol. You can find the list of culture names at https://msdn.microsoft.com/en-us/library/cc233982.aspx.</p><p>Example:</p><pre><div>culture: fr-FR </div></pre><h3 id="detectionrules">DetectionRules</h3><p>Few expressions that uniquely identify the document design. The expression can be exact phrase or contain macros and regular expressions (Regex).</p><p>Example:</p><pre><div>detectionRules: keywords: - ACME Inc\. - 'Invoice No:' - \[CONFIDENTIAL\] </div></pre><h3 id="documentstart">DocumentStart</h3><p>If your PDF file contains multiple documents to parse, documentStart expression should indicate the beginning of new document in PDF file.</p><p>Example:</p><pre><div>documentStart: TAX INVOICE </div></pre><h2 id="fields">Fields</h2><p>Standalone fields to extract. For example, invoice number, invoice date, etc.</p><p>Field parameters:</p><ul><li><p>type - [optional] Type of the field.</p><p>Valid values:</p><ul><li>macros - (default) A field that contains macros or regular expression (Regex).</li><li>rectangle - Rectangular area of the document page to extract text from. The rectangle coordinates are defined in rectangle parameter. If used without the expression parameter, it will simply return the text extracted from the rectangle. If used with the expression parameter, the expression will only search within the text extracted from the rectangle.</li><li>static - Static text that will be passed to the result without changes.</li><li>structure - Virtual table structure field. The parser tries to reconstruct a tabular structure of the document page and allows you to specify coordinates of desired field in this structure. Use pageIndex and structureCoordinates parameters to specify the coordinates. Use Template Editor to select structure coordinates visually.</li><li>direction - Directional field. Allows to find a fixed keyword phrase and take Nth phrase from it as value. Use expression parameter to specify the keyword phrase, and keywordOrdinalNumber, valueOrdinalNumber parameters to specify the criteria.</li></ul><p>Examples of fields of different types:</p><pre><div>fields:

# regex field total: type: macros expression: ‘TOTAL:’ dataType: decimal

# rectangle field billTo: type: rectangle rectangle: - 32.5 - 64.5 - 200 - 100 expression: ‘Bill to:()’ pageIndex: 0

#static field companyName: type: static expression: ACME Inc.

# structure field structureField1: type: structure pageIndex: 0 structureCoordinates: x: 2 y: 4

# directional field userSsn: type: direction expression: SSN keywordOrdinalNumber: 2 valueDirection: right valueOrdinalNumber: 1 </div></code></pre></li><li><p>expression - Contains macros or a regular expression (Regex) defining the data to be searched and retrieved from the document.</p><p>By default, the entire matched expression will go to the result. If you need to have only a part of matched expression in the result, enclose that part in parenthesis.</p><p>The part of the expression in parenthesis is called “group”. The expression can contain multiple groups. To get only the specific group in the result, mark it with ?<value>. See examples below.</p><p>You can also use | symbol to construct logical "OR" expressions. See examples below.</p><p>Field expression can also contain the name of a special function. Currently available special functions:</p><ul><li>\(funcFindCompany</em> - searches the document for the company name from a predefined list of known companies.</li><li><em>\)funcFindCompanyNext - searches for the next company name from a predefined list of known companies.</li><li>\(funcFindMaxDate</em> - searches the document for the maximum date.</li><li><em>\)funcFindMinDate - searches the document for the minimum date.</li><li>$$funcFindMaxNumber - searches the document for the maximum number.</li></ul><p>Examples of expression parameter:</p><pre><div>fields:

billTo: # The entire match will go to the result. expression: ‘Bill to:

invoiceNo: # Only the part in parenthesis will go to the result. expression: ‘Invoice No.: ()

# Logical operation. The expression will match both $12.00 and €12.00 expression: ’(|())’

# Named group. Only the value of <value> named group will go to the result expression: ‘Total:(|)(?<value>)’

# Special function expression: $$funcFindCompany </div></code></pre></li><li><p>rectangle - [optional] coordinates of the extraction area for fields of the ‘rectangle’ type. The coordinates are specified as top, left, width, and height in PDF units Points (1 Point = 1/72").</p><p>Example:</p><pre><div>fields: billTo: type: rectangle rectangle: - 10 - 10 - 200 - 100 </div></pre></li><li><p>pageIndex - [optional] Zero-based page index to search the field in. Default is -1 (any page).</p></li><li><p>dataType - [optional] The expected datatype of the parsed value.</p><p>Possible values:</p><ul><li>string - used by default if the type is not specified; the matched Regex value will be passed to the result unchanged.</li><li>integer - the parser will try to convert the retrieved text to an integer number according to the template culture.</li><li>decimal - the parser will try to convert the retrieved text to a decimal number according to the template culture. See Note 1 below.</li><li>date - the retrieved text will be parsed as a date according to specified dateFormat or the template culture. See Note 2 below.</li><li>table - the special type used in conjunction with ‘rectangle’ field type. The data from the rectangle area will be extracted preserving the table structure.</li></ul></li><li><p>dateFormat - [optional] The format string to parse the date. See Note 2 below.</p></li><li><p>outputDateFormat - [optional] Output date format. By default, successfully parsed date will be passed to the result in ISO 8601 format, e.g. 2018-01-04T00:00:00, but you can specify your own output format, e.g. yyyy-MM-dd.</p></li><li><p>rowMergingRule - [optional] defines a rule to merge multiline data in table cells. Used with ‘rectangle’ field type and ‘table’ data type. See rowMergingRule description in tables section.</p></li><li><p>coalesceWith - name of another field to coalesce with. If the specified field is not parsed, the current field will replace it. This is useful if you need to create two parsing criteria for some varying data and get them as a single field in the result. If the first field fails, the second will be used.</p><p>Example. If field1 is not successfully parsed, the field1a will be used to replace field1 in the result:</p><pre><div>fields: field1: rect: - 10 - 10 - 100 - 25 field1a: rect: - 10 - 50 - 100 - 25 coalesceWith: field1 </div></pre></li><li><p>structureCoordinates - X and Y coordinates in the virtual table structure. You can use Use Template Editor to select structure coordinates visually.</p><p>Example:</p><pre><div># structure field structureField1: type: structure pageIndex: 0 structureCoordinates: x: 2 y: 4 </div></pre></li><li><p>keywordOrdinalNumber - For direction type fields. Ordinal number of the keyword phrase occurrence.</p></li><li><p>valueOrdinalNumber - For direction type fields. Ordinal number of the sentence to return as result. Sentence is a sequence of words separated by a single space.</p></li></ul><p>Note 1: If you come across different number representations in the same document, you can override the template culture by appending new culture to the data type name. This single field will be parsed according to the specified culture.</p><p>Example:</p><pre><div>type: decimal[fr-FR] </div></pre><p>Note 2: The dateFormat and outputDateFormat can contain a format string defining the exact date format. Find the format string description here: https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tryparseexact.</p><p>Example:</p><pre><div>type: date dateFormat: MM-dd-yyyy </div></pre><p>The dateFormat can also contain auto-format strings:</p><ul><li>auto-MDY - the parser will try to detect the date format automatically, assuming the date is in month-day-year sequence.</li><li>auto-DMY - the parser will try to detect the date format automatically, assuming the date is in day-month-year sequence.</li><li>auto-YMD - the parser will try to detect the date format automatically, assuming the date is in year-month-day sequence.</li><li>auto - the parser will try to detect the format automatically, taking the date parts sequence from the template culture.</li></ul><p>Example:</p><pre><div>type: date dateFormat: auto-DMY </div></pre><h2 id="tables">Tables</h2><p>This section defines tabular data you need to extract. Tables can be defined by coordinates or by expressions to find the table start, the end, and rows.Tables section can contain multiple table definitions arranged as an array.</p><p>Table parameters:</p><ul><li><p>name - table name to distinguish different tables in the result.</p></li><li><p>start - group of parameters that define the start of the table:</p><ul><li>expression - macro expression to find the start of the table, or</li><li>y - the top coordinate of the table.</li><li>pageIndex - index of the page containing the y coordinate.</li></ul></li><li><p>end - group of parameters that define the end of the table:</p><ul><li>expression - macro expression to find the end of the table, or</li><li>y - the bottom coordinate of the table.</li></ul></li><li><p>subItemStart - [optional] parameters that define the start of the table sub-item. Sub-items are used for tables with complex multiline rows:</p><ul><li>expression - macro expression to find the start of the sub-item.</li></ul></li><li><p>subItemEnd - [optional] parameters that define the end of the table sub-item:</p><ul><li>expression - macro expression to find the end of the sub-item.</li></ul></li><li><p>introduction - Parameters to parse values from sub-headers. Values parsed from the introduction expression will be repeated in the beginning of every row.</p><ul><li>expression - macro expression to parse introduction items.</li></ul></li><li><p>row - [optional] group of parameters that define table rows:</p><ul><li>expression - the main macro expression to find a row. Named groups in this expression will go to the result table as columns. See example below.</li><li>subExpression1, subExpression2, subExpression3, subExpression4, subExpression5 - additional expressions to parse some remaining parts of row data which the main expression cannot parse in one pass. Sub-expressions are executed after the main expression for the text chunks between matches of the main expression. Can be used to parse hanging rows (wrapped multiline cells).</li></ul></li><li><p>columns - [optional] array that defines column properties. Names of columns should correspond to the names of the capturing groups of the row expression.</p><p>Column properties:</p><ul><li>name - column name.</li><li>x - [optional] X coordinate of the left column edge in PDF Points;</li><li>type - [optional] Column data type: ‘string’, ‘integer’, ‘date’, or ‘decimal’ (see also the type descriptions in fields section).</li><li>dateFormat - [optional] See dateFormat description in fields section.</li><li>outputDateFormat - [optional] See outputDateFormat description in fields section.</li><li>coalesceWith - [optional] Name of column to merge the parsed value with.</li></ul><p>Example:</p><pre><div> columns: - name: exam x: 0 type: string - name: examDate x: 100 type: date dateFormat: auto-MDY </div></pre></li><li><p>rowMergingRule - [optional] For the fields of rectangle type and table data type. Defines the rule to merge multiline data in table cells.</p><p>Valid values:</p><ul><li>none - default, no rule.</li><li>byBorders - combine lines within a table cell framed by border lines.</li><li>hangingRows - join table row that contains only a single cell up to the previous row if there is no separating line between them. Useful for tables without borders between rows.</li></ul><p>Example:</p><pre><div>rowMergingRule: byBorders </div></pre></li><li><p>multipage - [optional] defines whether the table may continue on further pages.</p><p>Example:</p><pre><div>multipage: true </div></pre></li></ul><p>Example of table parsing:</p><table><thead><tr><th style="text-align:left">Description</th><th style="text-align:center">Interval</th><th style="text-align:right">Quantity</th><th style="text-align:right">Amount ($)</th></tr></thead><tbody><tr><td style="text-align:left">Basic Plan</td><td style="text-align:center">Jan 1 - Jan 31</td><td style="text-align:right">1</td><td style="text-align:right">25.00</td></tr><tr><td style="text-align:left">Basic Plan</td><td style="text-align:center">Feb 1 - Feb 28</td><td style="text-align:right">1</td><td style="text-align:right">25.00</td></tr><tr><td style="text-align:left"></td><td style="text-align:center"></td><td style="text-align:right">Total in USD:</td><td style="text-align:right">50.00</td></tr></tbody></table><p>The table above, can be parsed with macro expressions or with explicitly defined column coordinates.</p><p>Macros approach:</p><pre><div>tables: - name: table1 start: # The table will start after the text "Amount ($)" expression: 'Amount' end: # The table will end before the text "Total in USD" expression: Total in USD row: # Groups <description>, <interval>, <quantity>, and <amount> will become columns in the result table. expression: '(?<description>)(?<interval>)(?<quantity>)(?<amount>)' columns: # Suggest data types for table columns: - name: description type: string - name: interval type: string - name: quantity type: integer - name: amount type: decimal </div></pre><p>If the macros approach is impossible for some complicated table, you can specify column coordinates explicitly. To visually determine the coordinates of a column, you can use included Template Editor application: it shows cursor coordinates in the toolbar.</p><p>Explicit column coordinates approach:</p><pre><div>tables: - name: table1 start: # The table will start below the text "Description Interval" expression: 'DescriptionInterval' end: # The table will end above the text "Total in USD" expression: 'Total in USD' columns: # Suggest coordinates and data types for table columns - name: description x: 0 type: string - name: interval x: 100 type: string - name: quantity x: 150 type: integer - name: amount x: 200 type: decimal </div></pre><h2 id="options">Options</h2><p>Template options.</p><ul><li><p>ocrLanguage - The language for Optical Character Recognition (OCR). Five base languages are supported out of the box. Dozens of other languages are supported as well as mixed language documents (with 2 or more languages used on the same page or document), please contact us for help with the setup of multiple languages.</p><p>Valid values:</p><ul><li>eng - English (default)</li><li>deu - German</li><li>fra - French</li><li>spa - Spanish</li><li>nld - Dutch</li></ul><p>Example:</p><pre><div>ocrLanguage: nld </div></pre></li><li><p>ocrMode - The mode of the Optical Character Recognition (OCR):</p><ul><li>auto - OCR will be used only if there are no text on PDF document page but only raster images.</li><li>forced - Force OCR to extract text from both images and fonts. Useful for PDF documents with mixed content (when portion of document text is drawn as image).</li><li>repairFonts - Some PDF documents use embedded fonts with customized charset making the text extraction impossible. This mode will render entire document and extract the text using OCR.</li></ul><p>Example:</p><pre><div>ocrMode: forced </div></pre></li></ul><h2 id="template-level-macros">Template-level macros</h2><p>Template-level (TL) macros allow to define reusable blocks that you can use in expression parameters of fields and tables.</p><p>TL macro can contain built-in macros and regular expressions (Regex).</p><p>TL macro can reuse macros defined above in the template code.</p><p>TL macros in expression should be enclosed in double angle brackets: << >>.</p><p>Example:</p><pre><div>templateMacros: # Detects "Yes" or "No" in the text yesOrNo: '(Yes|No)' # Detects "12/01/2019 - 12/31/2019" date range in the text dateRange: ' ' # Detects 24h time "13:00" in the text time: '' # Detects "08:00-17:00" time range in the text. Example of reusing the macro defined above. timeRange: '<<time>><<time>>'

# Example of use of template-level macros defined in templateMacros section fields: answer: expression: ‘Answer: (<<yesOrNo>>)’ period: expression: ‘<<dateRange>>’ workHours: expression: ‘<<timeRange>>’ workHoursStart: expression: ’(?<value><<time>>)<<time>>’ workHoursEnd: expression: ‘<<time>>(?<value><<time>>)’ </div></code></pre><h2 id="appendix-1">APPENDIX 1: Macros.</h2><p>Built-in macros:</p><table><thead><tr><th>Macro</th><th>Description</th></tr></thead><tr><td></td><td>Tries to detect the date in the most common formats.</td></tr><tr><td></td><td>Decimal number like the following: "12.34", "-123,456.78", "123.456". Decimal separator and thousands separator are automatically taken from the template culture.</td></tr><tr><td></td><td>Decimal number with currency symbol like the following: "USD 12.34", "$123,456.78", "123.45 €". Decimal separator and thousands separator are automatically taken from the template culture.</td></tr><tr><td></td><td>Single space.</td></tr><tr><td></td><td>One or more spaces.</td></tr><tr><td></td><td>Two spaces.</td></tr><tr><td></td><td>Three spaces.</td></tr><tr><td></td><td>Four spaces.</td></tr><tr><td></td><td>Five spaces.</td></tr><tr><td></td><td>Six spaces.</td></tr><tr><td></td><td>Seven spaces.</td></tr><tr><td></td><td>Eight spaces.</td></tr><tr><td></td><td>Nine spaces.</td></tr><tr><td></td><td>Ten spaces.</td></tr><tr><td></td><td>One digit.</td></tr><tr><td></td><td>One or more digits.</td></tr><tr><td></td><td>Two digits.</td></tr><tr><td></td><td>Three digits.</td></tr><tr><td></td><td>Four digits.</td></tr><tr><td></td><td>Five digits.</td></tr><tr><td></td><td>Six digits.</td></tr><tr><td></td><td>Seven digits.</td></tr><tr><td></td><td>Eight digits.</td></tr><tr><td></td><td>Nine digits.</td></tr><tr><td></td><td>Ten digits.</td></tr><tr><td></td><td>One digit or symbol ("-+=/").</td></tr><tr><td></td><td>One or more digits or symbols ("-+=/").</td></tr><tr><td></td><td>Two digits or symbols ("-+=/").</td></tr><tr><td></td><td>Three digits or symbols ("-+=/").</td></tr><tr><td></td><td>Four digits or symbols ("-+=/").</td></tr><tr><td></td><td>Five digits or symbols ("-+=/").</td></tr><tr><td></td><td>Six digits or symbols ("-+=/").</td></tr><tr><td></td><td>Seven digits or symbols ("-+=/").</td></tr><tr><td></td><td>Eight digits or symbols ("-+=/").</td></tr><tr><td></td><td>Nine digits or symbols ("-+=/").</td></tr><tr><td></td><td>Ten digits or symbols ("-+=/").</td></tr><tr><td></td><td>One letter from any language.</td></tr><tr><td></td><td>One or more letters from any language.</td></tr><tr><td></td><td>Two letters from any language.</td></tr><tr><td></td><td>Three letters from any language.</td></tr><tr><td></td><td>Four letters from any language.</td></tr><tr><td></td><td>Five letters from any language.</td></tr><tr><td></td><td>Six letters from any language.</td></tr><tr><td></td><td>Seven letters from any language.</td></tr><tr><td></td><td>Eight letters from any language.</td></tr><tr><td></td><td>Nine letters from any language.</td></tr><tr><td></td><td>Ten letters from any language.</td></tr><tr><td></td><td>One uppercase letter from any language.</td></tr><tr><td></td><td>One or more uppercase letters from any language.</td></tr><tr><td></td><td>Two uppercase letters from any language.</td></tr><tr><td></td><td>Three uppercase letters from any language.</td></tr><tr><td></td><td>Four uppercase letters from any language.</td></tr><tr><td></td><td>Five uppercase letters from any language.</td></tr><tr><td></td><td>Six uppercase letters from any language.</td></tr><tr><td></td><td>Seven uppercase letters from any language.</td></tr><tr><td></td><td>Eight uppercase letters from any language.</td></tr><tr><td></td><td>Nine uppercase letters from any language.</td></tr><tr><td></td><td>Ten uppercase letters from any language.</td></tr><tr><td></td><td>One letter or digit.</td></tr><tr><td></td><td>One or more letters or digits.</td></tr><tr><td></td><td>Two letters or digits.</td></tr><tr><td></td><td>Three letters or digits.</td></tr><tr><td></td><td>Four letters or digits.</td></tr><tr><td></td><td>Five letters or digits.</td></tr><tr><td></td><td>Six letters or digits.</td></tr><tr><td></td><td>Seven letters or digits.</td></tr><tr><td></td><td>Eight letters or digits.</td></tr><tr><td></td><td>Nine letters or digits.</td></tr><tr><td></td><td>Ten letters or digits.</td></tr><tr><td></td><td>One uppercase letter or digit.</td></tr><tr><td></td><td>One or more uppercase letters or digits.</td></tr><tr><td></td><td>Two uppercase letters or digits.</td></tr><tr><td></td><td>Three uppercase letters or digits.</td></tr><tr><td></td><td>Four uppercase letters or digits.</td></tr><tr><td></td><td>Five uppercase letters or digits.</td></tr><tr><td></td><td>Six uppercase letters or digits.</td></tr><tr><td></td><td>Seven uppercase letters or digits.</td></tr><tr><td></td><td>Eight uppercase letters or digits.</td></tr><tr><td></td><td>Nine uppercase letters or digits.</td></tr><tr><td></td><td>Ten uppercase letters or digits.</td></tr><tr><td></td><td>One letter, or digit, or symbol ("-+=/").</td></tr><tr><td></td><td>One or more letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Two letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Three letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Four letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Five letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Six letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Seven letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Eight letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Nine letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Ten letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>One uppercase letter, or digit, or symbol ("-+=/").</td></tr><tr><td></td><td>One or more uppercase letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Two uppercase letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Three uppercase letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Four uppercase letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Five uppercase letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Six uppercase letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Seven uppercase letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Eight uppercase letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Nine uppercase letters, or digits, or symbols ("-+=/").</td></tr><tr><td></td><td>Ten uppercase letters, or digits, or symbols ("_-+=/").</td></tr><tr><td></td><td>Dollar sign ($).</td></tr><tr><td></td><td>Euro sign (€).</td></tr><tr><td></td><td>Pound sign (£).</td></tr><tr><td></td><td>Yen sign (¥).</td></tr><tr><td></td><td>Yuan sign (¥).</td></tr><tr><td></td><td>Any currency symbol ($, €, £, ¥, etc.)</td></tr><tr><td></td><td>Single dot symbol (".").</td></tr><tr><td></td><td>Single comma symbol (",").</td></tr><tr><td></td><td>Single colon symbol (":").</td></tr><tr><td></td><td>Single semicolon symbol (";").</td></tr><tr><td></td><td>Single minus (dash, hyphen) symbol ("-").</td></tr><tr><td></td><td>Slash symbol ("/").</td></tr><tr><td></td><td>Backslash symbol ("\").</td></tr><tr><td></td><td>Percent symbol ("%").</td></tr><tr><td></td><td>Start of line (virtual symbol).</td></tr><tr><td></td><td>End of line (virtual symbol).</td></tr><tr><td></td><td>Single-space-separated sequence of words and symbols. Breaks on double space.</td></tr><tr><td></td><td>Extended macro allowing two spaces between words. Breaks on triple space.</td></tr><tr><td></td><td>End of page or end of document.</td></tr><tr><td></td><td>Start or end of word (virtual symbol).</td></tr><tr><td></td><td>Opening curly brace symbol ("{").</td></tr><tr><td></td><td>Closing curly brace symbol ("}").</td></tr><tr><td></td><td>Opening parenthesis symbol ("(").</td></tr><tr><td></td><td>Closing parenthesis symbol (")").</td></tr><tr><td></td><td>Opening square bracket symbol ("[").</td></tr><tr><td></td><td>Closing square bracket symbol ("]").</td></tr><tr><td></td><td>Opening angle bracket symbol ("<").</td></tr><tr><td></td><td>Closing angle bracket symbol (">").</td></tr><tr><td></td><td>Date in format "01/01/19" (with leading zero).</td></tr><tr><td></td><td>Date in format "1/1/19" (without leading zero).</td></tr><tr><td></td><td>Date in format "01/01/2019" (with leading zero).</td></tr><tr><td></td><td>Date in format "1/1/2019" (without leading zero).</td></tr><tr><td></td><td>Date in format "01-01-19" (with leading zero).</td></tr><tr><td></td><td>Date in format "1-1-19" (without leading zero).</td></tr><tr><td></td><td>Date in format "01-01-2019" (with leading zero).</td></tr><tr><td></td><td>Date in format "1-1-2019" (without leading zero).</td></tr><tr><td></td><td>Date in format "01.01.19" (with leading zero).</td></tr><tr><td></td><td>Date in format "1.1.19" (without leading zero).</td></tr><tr><td></td><td>Date in format "01.01.2019" (with leading zero).</td></tr><tr><td></td><td>Date in format "01.01.2019" (without leading zero).</td></tr><tr><td></td><td>Date in format "01/01/19" (with leading zero).</td></tr><tr><td></td><td>Date in format "1/1/19" (without leading zero).</td></tr><tr><td></td><td>Date in format "01/01/2019" (with leading zero).</td></tr><tr><td></td><td>Date in format "1/1/2019" (without leading zero).</td></tr><tr><td></td><td>Date in format "01-01-19" (with leading zero).</td></tr><tr><td></td><td>Date in format "1-1-19" (without leading zero).</td></tr><tr><td></td><td>Date in format "01-01-2019" (with leading zero).</td></tr><tr><td></td><td>Date in format "1-1-2019" (without leading zero).</td></tr><tr><td></td><td>Date in format "01.01.19" (with leading zero).</td></tr><tr><td></td><td>Date in format "1.1.19" (without leading zero).</td></tr><tr><td></td><td>Date in format "01.01.2019" (with leading zero).</td></tr><tr><td></td><td>Date in format "1.1.2019" (without leading zero).</td></tr><tr><td></td><td>Date in format "20190101".</td></tr><tr><td></td><td>Date in format "2019/01/01" (with leading zero).</td></tr><tr><td></td><td>Date in format "2019/1/1" (without leading zero).</td></tr><tr><td></td><td>Date in format "2019-01-01" (with leading zero).</td></tr><tr><td></td><td>Date in format "2019-1-1" (without leading zero).</td></tr><tr><td></td><td>Any characters up to the next macro in the expression.</td></tr><tr><td></td><td>Any characters up to the next macro in the expression or to the end of line. Greedy version.</td></tr><tr><td></td><td>Enables or disables single-line mode. In single-line mode, and macros do not stop at the end of the line and proceed to the next line of text.</td></tr><tr><td></td><td>Enables or disables case-insensitive mode.</td></tr></table><p></p><h2 id="appendix-2">APPENDIX 2: Sample templates.</h2><h3>Sample 1.</h3><p>Sample document text:</p><pre><div> DigitalOcean 101 Avenue of the Americas, 10th Floor New York, NY 10013 Date Issued: February 1, 2016 Period: January 1 - 31, 2016 Invoice Number: 1234567

    Description                                 Hours     Start          End            USD
    Website-Dev (1GB)                           744       01-01 00:00    01-31 23:59    $10.00
    Website-Live (1GB)                          744       01-01 00:00    01-31 23:59    $10.00
    Database-Live (2GB)                         744       01-01 00:00    01-31 23:59    $20.00
    Tasks-Dev (1GB)                             744       01-01 00:00    01-31 23:59    $10.00
                                                                                 Total: $50.00

 Bill To:
 Samee Sikka &lt;admin@meee.org&gt;
 meee.org
 Gouran

    If you have a credit card on file it will be automatically charged within 24 hours.

</div></code></code></pre><p>Sample template (YAML):</p><pre><div>--- templateVersion: 3 templatePriority: 0 sourceId: DigitalOcean Invoice detectionRules: keywords: # Template will match documents containing the following phrases: - 'DigitalOcean' - '101 Avenue of the Americas' - 'Invoice Number' fields: # Static field that will output "DigitalOcean" to the result companyName: type: static expression: DigitalOcean # Macro field that will find the text "Invoice Number: 1234567" and return "1234567" to the result invoiceId: type: macros expression: 'Invoice Number: ()' # Macro field that will find the text "Date Issued: February 1, 2016" and return the date "February 1, 2016" in ISO format to the result dateIssued: type: macros expression: 'Date Issued: ()' dataType: date dateFormat: auto-mdy # Macro field that will find the text "Total: $50.00" and return "50.00" to the result total: type: macros expression: 'Total: ()' dataType: decimal # Static field that will "USD" to the result currency: type: static expression: USD tables: - name: table1 # The table will start after the text "Description Hours" start: expression: 'DescriptionHours' # The table will end before the text "Total:" end: expression: 'Total:' # Macro expression that will find table rows "Website-Dev (1GB) 744 01-01 00:00 01-31 23:59 $10.00", etc. row: # Groups <description>, <hours>, <start>, <end> and <unitPrice> will become columns in the result table. expression: '(?<description>)(?<hours>)(?<start>)(?<end>)(?<unitPrice>)' # Suggest data types for table columns (missing columns will have the default "string" type): columns: - name: hours type: integer - name: unitPrice type: decimal </div></pre><p>Result (JSON):</p><pre><div>{ "templateId": "DigitalOcean.yml", "templateVersion": "3", "sourceId": "DigitalOcean Invoice", "fields": { "companyName": { "value": "DigitalOcean" }, "invoiceId": { "value": "1234567", "pageIndex": 0 }, "dateIssued": { "value": "2016-02-01T00:00:00", "pageIndex": 0 }, "total": { "value": 50.00, "pageIndex": 0 }, "currency": { "value": "USD" } }, "tables": [ { "name": "table1", "rows": [ { "description": { "value": "Website-Dev (1GB)", "pageIndex": 0 }, "hours": { "value": 744, "pageIndex": 0 }, "start": { "value": "01-01 00:00", "pageIndex": 0 }, "end": { "value": "01-31 23:59", "pageIndex": 0 }, "unitPrice": { "value": 10.00, "pageIndex": 0 } }, { "description": { "value": "Website-Live (1GB)", "pageIndex": 0 }, "hours": { "value": 744, "pageIndex": 0 }, "start": { "value": "01-01 00:00", "pageIndex": 0 }, "end": { "value": "01-31 23:59", "pageIndex": 0 }, "unitPrice": { "value": 10.00, "pageIndex": 0 } }, { "description": { "value": "Database-Live (2GB)", "pageIndex": 0 }, "hours": { "value": 744, "pageIndex": 0 }, "start": { "value": "01-01 00:00", "pageIndex": 0 }, "end": { "value": "01-31 23:59", "pageIndex": 0 }, "unitPrice": { "value": 20.00, "pageIndex": 0 } }, { "description": { "value": "Tasks-Dev (1GB)", "pageIndex": 0 }, "hours": { "value": 744, "pageIndex": 0 }, "start": { "value": "01-01 00:00", "pageIndex": 0 }, "end": { "value": "01-31 23:59", "pageIndex": 0 }, "unitPrice": { "value": 10.00, "pageIndex": 0 } } ] } ] } </div></pre><hr><p>Copyright (c) 2018-2020 ByteScout, Inc.</p><p>PDF.co with Web API and Document Parser</p><p>ByteScout</p>


Copyright © 2016 - 2021 ByteScout