Parsing and reading data from Airline Tickets - VB.NET
Document Parser SDK sample in VB.NET demonstrating ‘Parsing and reading data from Airline Tickets’
Module1.vb
Imports ByteScout.DocumentParser
' This example demonstrates document data parsing to JSON, YAML and XML formats.
Module Module1
Sub Main()
Dim templatesDocument As String = ".\SampleTicket.yml"
Dim inputDocument As String = ".\SampleTicket.pdf"
' Create DocumentParser instance
Using documentParser As New DocumentParser("demo", "demo")
' Loading template
documentParser.AddTemplate(templatesDocument)
' Parse document 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)
Console.WriteLine(Environment.NewLine + Environment.NewLine + "==================" + Environment.NewLine + Environment.NewLine)
' Parse document data in YAML format
Dim yamlString As String = documentParser.ParseDocument(inputDocument, OutputFormat.YAML)
' Display parsed data in console
Console.WriteLine("Parsing results in YAML format:")
Console.WriteLine()
Console.WriteLine(yamlString)
Console.WriteLine(Environment.NewLine + Environment.NewLine + "==================" + Environment.NewLine + Environment.NewLine)
' Parse document data in YAML format
Dim xmlString As String = documentParser.ParseDocument(inputDocument, OutputFormat.XML)
' Display parsed data in console
Console.WriteLine("Parsing results in XML format:")
Console.WriteLine()
Console.WriteLine(xmlString)
End Using
Console.WriteLine()
Console.WriteLine("Press any key to continue...")
Console.ReadLine()
End Sub
End Module
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