'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsSystem.Collections.GenericImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Pdf.AnnotationsImportsGrapeCity.Documents.Common PublicClassMarkupPerWordPublicFunctionCreatePDF(ByVal stream AsStream) AsIntegerConstword0AsString = "JavaScript"Constword1AsString = "framework" ' Load the PDF:Dim doc = NewGcPdfDocument()Using fs = File.OpenRead(Path.Combine("Resources", "PDFs", "CompleteJavaScriptBook.pdf")) doc.Load(fs) ' A FindTextParams for each of the search words:Dim ft0 = NewFindTextParams(word0, wholeWord:=False, matchCase:=False, regex:=False)Dim ft1 = NewFindTextParams(word1, wholeWord:=False, matchCase:=False, regex:=False) ' Find and highlight words on the pages, caching and reusing the text map' of each page for the two searches:ForEach p In doc.Pages' Find and highlight the first word:Dim textMap = p.GetTextMap()Dim markup0 AsTextMarkupAnnotation = NothingDim area0 AsList(OfQuadrilateral) = Nothing textMap.FindText(ft0, Sub(fp_)If markup0 IsNothingThen markup0 = NewTextMarkupAnnotation() With { .Subject = word0, .Page = doc.Pages(fp_.PageIndex), .MarkupType = TextMarkupType.Highlight, .Color = Color.Cyan }EndIfIf area0 IsNothingThen area0 = NewList(OfQuadrilateral)()EndIfForEach b In fp_.Bounds area0.Add(b)NextEndSub)If markup0 IsNotNothingThen markup0.Area = area0EndIf ' Find and highlight the second word:Dim markup1 AsTextMarkupAnnotation = NothingDim area1 AsList(OfQuadrilateral) = Nothing textMap.FindText(ft1, Sub(fp_)If markup1 IsNothingThen markup1 = NewTextMarkupAnnotation() With { .Subject = word1, .Page = doc.Pages(fp_.PageIndex), .MarkupType = TextMarkupType.Highlight, .Color = Color.Fuchsia }EndIfIf area1 IsNothingThen area1 = NewList(OfQuadrilateral)()EndIfForEach b In fp_.Bounds area1.Add(b)NextEndSub)If markup1 IsNotNothingThen markup1.Area = area1EndIfNext ' Done: doc.Save(stream)Return doc.Pages.CountEndUsingEndFunctionEndClass