//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingSystem.Drawing;usingGrapeCity.Documents.Pdf;usingGrapeCity.Documents.Pdf.Annotations;usingSystem.Collections.Generic;usingGrapeCity.Documents.Common; namespaceDsPdfWeb.Demos{// This example shows how to find all occurrences of a phrase in a PDF document and// highlight all those occurrences using the text markup squiggly underline annotation.// To ensure that all occurrences of the phrase ("javascript framework") are found// even if the words are separated by a line break, a regular expressions is used// in the search string.publicclassFindAndSquiggly {publicintCreatePDF(Stream stream) {// Load the PDF:var doc = newGcPdfDocument();usingvar fs = File.OpenRead(Path.Combine("Resources", "PDFs", "CompleteJavaScriptBook.pdf")); doc.Load(fs); // Find all occurrences of the phrase "javascript framework" using regex so that// words separated by line breaks are found:var ft = newFindTextParams("javascript\\s+framework", wholeWord: false, matchCase: false, regex: true);var found = doc.FindText(ft, null); // Add a text markup annotation to wavy underline each occurrence:foreach (var f in found) {var markup = newTextMarkupAnnotation() {Page = doc.Pages[f.PageIndex],MarkupType = TextMarkupType.Squiggly,Color = Color.Magenta };List<Quadrilateral> area = newList<Quadrilateral>();foreach (var b in f.Bounds) area.Add(b); markup.Area = area; } // Done: doc.Save(stream);return doc.Pages.Count; } }}