Sample source code below will display you how to manage a complex task like regular expression search and highlight in PDF in VB.NET. ByteScout PDF Suite is the bundle that provides six different SDK libraries to work with PDF from generating rich PDF reports to extracting data from PDF documents and converting them to HTML. This bundle includes PDF (Generator) SDK, PDF Renderer SDK, PDF Extractor SDK, PDF to HTML SDK, PDF Viewer SDK and PDF Generator SDK for Javascript. It can be applied to regular expression search and highlight in PDF using VB.NET.
Want to quickly learn? This fast application programming interfaces of ByteScout PDF Suite for VB.NET plus the guidelines and the code below will help you quickly learn how to regular expression search and highlight in PDF. This VB.NET sample code is all you need for your app. Just copy and paste the code, add references (if needs to) and you are all set! Enjoy writing a code with ready-to-use sample codes in VB.NET.
Trial version of ByteScout PDF Suite is available for free. Source code samples are included to help you with your VB.NET app.
On-demand (REST Web API) version:
Web API (on-demand version)
On-premise offline SDK for Windows:
60 Day Free Trial (on-premise)
Imports System.Drawing Imports Bytescout.PDF Imports Bytescout.PDFExtractor Module Module1 Sub Main() Dim inputFile As String = ".\sample.pdf" Dim pageIndex As Integer = 0 Dim searchPattern As String = "\d+\.\d+" ' Prepare TextExtractor Using textExtractor As TextExtractor = New TextExtractor("demo", "demo") textExtractor.RegexSearch = true textExtractor.LoadDocumentFromFile(inputFile) ' Load document with PDF SDK Using pdfDocument As Document = New Document(inputFile) pdfDocument.RegistrationName = "demo" pdfDocument.RegistrationKey = "demo" Dim pdfDocumentPage As Page = pdfDocument.Pages(pageIndex) Dim canvas As Canvas = pdfDocumentPage.Canvas Dim fillBrush As Bytescout.PDF.SolidBrush = new Bytescout.PDF.SolidBrush(new ColorRGB(255, 0, 0)) fillBrush.Opacity = 50 ' make the brush transparent ' Search for pattern and highlight found pieces If textExtractor.Find(pageIndex, searchPattern, caseSensitive := False) Do For Each foundPiece In textExtractor.FoundText.Elements ' Inflate the rectangle a bit Dim rect As RectangleF = RectangleF.Inflate(foundPiece.Bounds, 1, 2) ' Draw rectangle over the PDF page canvas.DrawRectangle(fillBrush, rect) Next Loop While textExtractor.FindNext() End If ' Save as new PDF document pdfDocument.Save("result.pdf") ' Open result document in default associated application (for demo purposes) Process.Start("result.pdf") End Using End Using End Sub End Module
60 Day Free Trial or Visit ByteScout PDF Suite Home Page
Explore ByteScout PDF Suite Documentation
Explore Samples
Sign Up for ByteScout PDF Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
60 Day Free Trial or Visit ByteScout PDF Suite Home Page
Explore ByteScout PDF Suite Documentation
Explore Samples
Sign Up for ByteScout PDF Suite Online Training
Get Your API Key
Explore Web API Docs
Explore Web API Samples
also available as: