'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsSystem.Collections.GenericImportsGrapeCity.Documents.CommonImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Pdf.Layers PublicClassSearchInLayersPublicFunctionCreatePDF(ByVal stream AsStream) AsIntegerUsing fs = File.OpenRead(Path.Combine("Resources", "PDFs", "lang-layers.pdf"))Dim doc = NewGcPdfDocument() doc.Load(fs) Dim regex = "\b(Windows|macOS|Linux|Mac)\b"FindInLayer(doc, "English", regex, Color.FromArgb(100, Color.Red))FindInLayer(doc, "French", regex, Color.FromArgb(100, Color.Blue))FindInLayer(doc, "Russian", regex, Color.FromArgb(100, Color.Green)) ' Save the PDF: doc.Save(stream)Return doc.Pages.CountEndUsingEndFunction PrivateSharedSubFindInLayer(doc AsGcPdfDocument, layer AsString, text AsString, highlight AsColor)' Create a view state with just the specified layer visible:Dim viewState = NewViewState(doc) viewState.SetLayersUIStateExcept(False, layer) viewState.SetLayersUIState(True, layer) ' Create a FindTextParams using our custom view state' so that the search is limited to the specified layer only:Dim ftp = NewFindTextParams(text, False, False, viewState, 72.0F, 72.0F, True, True) ' Find all occurrences of the search text:Dim finds = doc.FindText(ftp, OutputRange.All) ' Highlight all occurrences on the specified layer only:ForEach find In findsForEach ql In find.BoundsDim g = doc.Pages(find.PageIndex).Graphics g.BeginLayer(layer) doc.Pages(find.PageIndex).Graphics.FillPolygon(ql, highlight) g.EndLayer()NextNextEndSubEndClass