Free Trial
Web API version
Licensing
Request A Quote
HAVE QUESTIONS OR NEED HELP? SUBMIT THE SUPPORT REQUEST FORM or write email to SUPPORT@BYTESCOUT.COM
Create Custom Template | VB.NET
Module1.vb:
VB
Imports ByteScout.DocumentParser ' This example demonstrates data parsing from an invoice using the custom template. Module Module1 Sub Main() Dim customTemplate As String = ".\SampleTemplate.yml" Dim inputDocument As String = ".\SampleInvoice.pdf" ' Create DocumentParser instance Using documentParser As New DocumentParser("demo", "demo") Console.WriteLine($"Loading template ""{customTemplate}""...") Console.WriteLine() documentParser.AddTemplate(customTemplate) Console.WriteLine($"Parsing ""{inputDocument}""...") Console.WriteLine() ' Parse invoice data in JSON format Dim jsonString As String = documentParser.ParseDocument(inputDocument, OutputFormat.JSON) ' Display parsed data in console Console.WriteLine("Parsing results in JSON format:") Console.WriteLine() Console.WriteLine(jsonString) End Using Console.WriteLine() Console.WriteLine("Press any key to continue...") Console.ReadLine() End Sub End Module
SampleTemplate.yml:
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
- name: dateIssued
objectType: field
fieldProperties:
fieldType: macros
expression: Invoice Date {{SmartDate}}
dataType: date
dateFormat: auto-mdy
pageIndex: 0
- name: invoiceId
objectType: field
fieldProperties:
fieldType: macros
expression: Invoice No. {{Digits}}
pageIndex: 0
- name: companyName
objectType: field
fieldProperties:
fieldType: static
expression: Vendor Company
pageIndex: 0
- name: billTo
objectType: field
fieldProperties:
fieldType: rectangle
rectangle:
- 32.25
- 150
- 348
- 70.5
pageIndex: 0
- name: notes
objectType: field
fieldProperties:
fieldType: rectangle
rectangle:
- 32.25
- 227.25
- 531
- 47.25
pageIndex: 0
- 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