//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingSystem.Drawing;usingGrapeCity.Documents.Common;usingGrapeCity.Documents.Pdf; namespaceDsPdfWeb.Demos{ // 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.publicclassFindText {publicintCreatePDF(Stream stream) { // The original file stream must be kept open while working with the loaded PDF, see LoadPDF for details:usingvar fs = File.OpenRead(Path.Combine("Resources", "PDFs", "BalancedColumns.pdf"));var doc = newGcPdfDocument(); doc.Load(fs);// Find all 'lorem', using case-insensitive word search:var findsLorem = doc.FindText(newFindTextParams("lorem", true, false),OutputRange.All);// Ditto for 'ipsum':var findsIpsum = doc.FindText(newFindTextParams("ipsum", true, false),OutputRange.All); // Highlight all 'lorem' using semi-transparent orange red:foreach (var find in findsLorem)foreach (var ql in find.Bounds) doc.Pages[find.PageIndex].Graphics.FillPolygon(ql, Color.FromArgb(100, Color.OrangeRed));// Put a violet red border around all 'ipsum':foreach (var find in findsIpsum)foreach (var ql in find.Bounds) doc.Pages[find.PageIndex].Graphics.DrawPolygon(ql, Color.MediumVioletRed); // Done: doc.Save(stream);return doc.Pages.Count; } }}