ByteScout PDF Extractor SDK - VB.NET - Find Keyword And Extract Text - ByteScout

ByteScout PDF Extractor SDK – VB.NET – Find Keyword And Extract Text

  • Home
  • /
  • Articles
  • /
  • ByteScout PDF Extractor SDK – VB.NET – Find Keyword And Extract Text

ByteScout PDF Extractor SDK – VB.NET – Find Keyword And Extract Text

Program.vb

Imports System.Drawing
Imports Bytescout.PDFExtractor

Namespace FindText

	Class Program

		Friend Shared Sub Main(args As String())

            ' Create Bytescout.PDFExtractor.TextExtractor instance
			Dim extractor As New TextExtractor()
			extractor.RegistrationName = "demo"
			extractor.RegistrationKey = "demo"

			' Load sample PDF document
			extractor.LoadDocumentFromFile(".\sample2.pdf")

			Dim pageCount As Integer = extractor.GetPageCount()

			' Search each page for some keyword 
			For i As Integer = 0 To pageCount - 1
				If extractor.Find(i, "References", False) Then
					' If page contains the keyword, extract a text from it.
					' For demonstration we'll extract the text from top part of the page only
					extractor.SetExtractionArea(0, 0, 600, 200)
					Dim text As String = extractor.GetTextFromPage(i)
					Console.WriteLine(text)
				End If
			Next

			' Cleanup
			extractor.Dispose()

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

		End Sub
		
	End Class

End Namespace


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next