'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Common '' This sample loads the PDF file created by the BalancedColumns sample,'' finds all occurrences of the words 'lorem' and 'ipsum' in the loaded document,'' and highlights these two words using different colors.PublicClassFindTextFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument() '' The original file stream must be kept open while working with the loaded PDF, see LoadPDF for details:Using fs = NewFileStream(Path.Combine("Resources", "PDFs", "BalancedColumns.pdf"), FileMode.Open, FileAccess.Read) doc.Load(fs)'' Find all 'lorem', using case-insensitive word search:Dim findsLorem = doc.FindText(NewFindTextParams("lorem", True, False),OutputRange.All)'' Ditto for 'ipsum':Dim findsIpsum = doc.FindText(NewFindTextParams("ipsum", True, False),OutputRange.All)'' Highlight all 'lorem' using semi-transparent orange red:ForEach find In findsLoremForEach ql In find.Bounds doc.Pages(find.PageIndex).Graphics.FillPolygon(ql, Color.FromArgb(100, Color.OrangeRed))NextNext'' Put a violet red border around all 'ipsum':ForEach find In findsIpsumForEach ql In find.Bounds doc.Pages(find.PageIndex).Graphics.DrawPolygon(ql, Color.MediumVioletRed)NextNext'''' Done: doc.Save(stream)EndUsingReturn doc.Pages.CountEndFunctionEndClass