'''' 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 PublicClassMarkupPerPagePublicFunctionCreatePDF(ByVal stream AsStream) AsInteger' Load the PDF:Dim doc = NewGcPdfDocument()Using fs = File.OpenRead(Path.Combine("Resources", "PDFs", "The-Rich-History-of-JavaScript.pdf")) doc.Load(fs) ' Find all occurrences of "JavaScript" or "ECMAScript" using regex:Dim ft = NewFindTextParams("JavaScript|ECMAScript", wholeWord:=False, matchCase:=False, regex:=True)Dim found = doc.FindText(ft, Nothing) ' Add a text markup annotation per page (keys are page indices):Dim markups AsNewDictionary(OfInteger, Tuple(OfTextMarkupAnnotation, List(OfQuadrilateral)))ForEach f In foundDim markup As Tuple(OfTextMarkupAnnotation, List(OfQuadrilateral)) = NothingIfNot markups.TryGetValue(f.PageIndex, markup) Then markup = New Tuple(OfTextMarkupAnnotation, List(OfQuadrilateral))(NewTextMarkupAnnotation() With { .Page = doc.Pages(f.PageIndex), .MarkupType = TextMarkupType.Highlight, .Color = Color.Chartreuse },NewList(OfQuadrilateral)()) markups(f.PageIndex) = markupEndIfForEach b In f.Bounds markup.Item2.Add(b)NextNextForEach v In markups.Values v.Item1.Area = v.Item2Next ' Done: doc.Save(stream)Return doc.Pages.CountEndUsingEndFunctionEndClass