ByteScout Document Parser SDK – VB.NET – Parse with OCR

  • Home
  • /
  • Articles
  • /
  • ByteScout Document Parser SDK – VB.NET – Parse with OCR

ByteScout Document Parser SDK – VB.NET – Parse with OCR

Module1.vb

Imports ByteScout.DocumentParser

' This example demonstrates the use of Optical Character Recognition (OCR) to parse document 
' from scanned PDF documents and raster images.

Module Module1

    Sub Main()

        Dim template As String = ".\DigitalOcean.yml"
        Dim inputDocument As String = ".\DigitalOcean-scanned.jpg"

        ' Create DocumentParser instance
        Using documentParser As New DocumentParser("demo", "demo")

            Console.WriteLine("Loading template...")

            documentParser.AddTemplate(template)


            ' Enable Optical Character Recognition (OCR)
            ' in .Auto mode (SDK automatically checks if needs to use OCR or not)
            documentParser.OCRMode = OCRMode.Auto
            
            ' Set the location of "tessdata" folder containing language data files
            documentParser.OCRLanguageDataFolder = ".\tessdata\"

            ' Set OCR language
            documentParser.OCRLanguage = "eng"
            ' "eng" for english, "deu" for German, "fra" for French, "spa" for Spanish etc - according to files in /tessdata
            ' Find more language files at https://github.com/tesseract-ocr/tessdata/tree/3.04.00

            Console.WriteLine($"Parsing ""{inputDocument}""...")
            Console.WriteLine()

            ' 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)
            
        End Using

        Console.WriteLine()
        Console.WriteLine("Press any key to continue...")
        Console.ReadLine()

    End Sub

End Module


  Click here to get your Free Trial version of the SDK

prev
next