Parsing and reading data from Airline Tickets - VBScript and VB6
Document Parser SDK sample in VBScript and VB6 demonstrating ‘Parsing and reading data from Airline Tickets’
GeneralExample.vbs
' This example demonstrates document data parsing to JSON and YAML formats.
templatesDocument = ".\SampleTicket.yml"
inputDocument = ".\SampleTicket.pdf"
' Create DocumentParser object
Set documentParser = CreateObject("Bytescout.DocumentParser.DocumentParser")
documentParser.RegistrationName = "demo"
documentParser.RegistrationKey = "demo"
' Loading template...
documentParser.AddTemplate templatesDocument
' Parse document data in JSON format
documentParser.ParseDocument inputDocument, "output1.json", 0 ' 0 = OutputFormat.JSON
' Parse document data in YAML format
documentParser.ParseDocument inputDocument, "output2.yaml", 1 ' 1 = OutputFormat.YAML
WScript.Echo "Parsed data saved as 'output1.json' and 'output2.yaml'."
Set documentParser = Nothing
SampleTicket.yml
templateName: MakeMyTrip Booking
templateVersion: 4
templatePriority: 0
detectionRules:
keywords:
- MakeMyTrip
- Eticket-Dom-Flight
objects:
- name: BookingNo
objectType: field
fieldProperties:
fieldType: rectangle
rectangle:
- 198.75
- 85.625
- 96.875
- 12.500001
pageIndex: 0
- name: BookingDate
objectType: field
fieldProperties:
fieldType: rectangle
dataType: date
rectangle:
- 133.125
- 97.5000076
- 78.75
- 12.500001
pageIndex: 0
- name: DepartureFrom
objectType: field
fieldProperties:
fieldType: rectangle
rectangle:
- 153
- 176
- 77
- 8.5
pageIndex: 0
- name: ArrivalTo
objectType: field
fieldProperties:
fieldType: rectangle
rectangle:
- 285
- 176
- 84
- 8.5
pageIndex: 0
- name: DepartureAt
objectType: field
fieldProperties:
fieldType: rectangle
dataType: date
rectangle:
- 153.75
- 187.5
- 123.75
- 10.625
pageIndex: 0
- name: ArrivalAt
objectType: field
fieldProperties:
fieldType: rectangle
dataType: date
rectangle:
- 288.125
- 186.875
- 125.625008
- 11.25
pageIndex: 0
- name: FlightType
objectType: field
fieldProperties:
fieldType: rectangle
rectangle:
- 433.5
- 159.5
- 68
- 10.5
pageIndex: 0
- name: FlightDuration
objectType: field
fieldProperties:
fieldType: rectangle
rectangle:
- 474.375031
- 170.625
- 30.0000019
- 10
pageIndex: 0
- name: CabinType
objectType: field
fieldProperties:
fieldType: rectangle
rectangle:
- 463.125031
- 194.375015
- 51.25
- 10
pageIndex: 0
- name: PassengerName
objectType: field
fieldProperties:
fieldType: rectangle
rectangle:
- 85
- 238.125
- 93.125
- 14.375
pageIndex: 0
- name: PassengerType
objectType: field
fieldProperties:
fieldType: rectangle
rectangle:
- 229.375015
- 238.125
- 31.25
- 13.75
pageIndex: 0
- name: AirlinePNR
objectType: field
fieldProperties:
fieldType: rectangle
rectangle:
- 375
- 240.000015
- 46.25
- 13.75
pageIndex: 0