{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "pdf-viewer-text-search",
  "framework": "maui",
  "type": "registry:component",
  "component": "PdfViewer",
  "variant": "text-search",
  "dependencies": [
    "Syncfusion.Maui.PdfViewer"
  ],
  "description": "PDF viewer enables document text search with custom highlight colors and match navigation.",
  "meta": {
    "essentialStudioRelease": "2026 Volume 3 (v35.1.37)",
    "license": "commercial-or-community",
    "licenseNote": "The Syncfusion package is licensed. The composition in this file is source you own and edit. See https://ai.syncfusion.com/licensing.md",
    "requiresLicenseKey": true,
    "requiresServerEndpoint": false,
    "platformIndex": "https://ai.syncfusion.com/maui/llms.txt",
    "skillPack": "syncfusion/maui-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/maui/pdf-viewer-text-search.md"
  },
  "files": [
    {
      "target": "src/components/pdf-viewer-text-search/PdfViewer.xaml",
      "content": "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<ContentPage xmlns=\"http://schemas.microsoft.com/dotnet/2021/maui\"\r\n             xmlns:x=\"http://schemas.microsoft.com/winfx/2009/xaml\"\r\n             xmlns:pdf=\"clr-namespace:Syncfusion.Maui.PdfViewer;assembly=Syncfusion.Maui.PdfViewer\"\r\n             xmlns:model=\"clr-namespace:MAUI.Controls.PdfViewer.TextSearch\"\r\n             x:Class=\"MAUI.Controls.PdfViewer.TextSearch.PdfViewerView\"\r\n             x:DataType=\"model:PdfViewerViewModel\"\r\n             Title=\"PDF Viewer - Text Search\">\r\n    <ContentPage.Content>\r\n        <Grid>\r\n            <Grid.RowDefinitions>\r\n                <RowDefinition Height=\"45\"/>\r\n                <RowDefinition Height=\"*\"/>\r\n            </Grid.RowDefinitions>\r\n\r\n            <!-- Toolbar: Contains title and buttons for search actions -->\r\n            <ScrollView Orientation=\"Horizontal\"\r\n                    HorizontalScrollBarVisibility=\"Never\">\r\n                <Grid ColumnDefinitions=\"Auto, *\">\r\n                    <!-- Title Label on the Left -->\r\n                    <Label Text=\"PDF Viewer\"\r\n                            FontSize=\"16\"\r\n                            VerticalOptions=\"Center\"\r\n                            Grid.Column=\"0\"/>\r\n\r\n                    <!-- Button Container with Spacing -->\r\n                    <HorizontalStackLayout Grid.Column=\"1\"\r\n                            Spacing=\"10\"\r\n                            HorizontalOptions=\"End\"\r\n                            Padding=\"0,0,15,0\">\r\n                        <Button Text=\"&#xE715;\"\r\n                                FontFamily=\"MauiMaterialAssets\"\r\n                                Clicked=\"SearchButtonClicked\"/>\r\n                        <!-- Starts search -->\r\n                        <Button Text=\"&#xE707;\"\r\n                                FontFamily=\"MauiMaterialAssets\"\r\n                                Clicked=\"PreviousMatchButtonClicked\"/>\r\n                        <!-- Moves to previous match -->\r\n                        <Button Text=\"&#xE706;\"\r\n                                FontFamily=\"MauiMaterialAssets\"\r\n                                Clicked=\"NextMatchButtonClicked\"/>\r\n                        <!-- Moves to next match -->\r\n                        <Button Text=\"&#xE70B;\"\r\n                                FontFamily=\"MauiMaterialAssets\"\r\n                                Clicked=\"CloseSearchButtonClicked\"/>\r\n                        <!-- Clears search results -->\r\n                    </HorizontalStackLayout>\r\n                </Grid>\r\n            </ScrollView>\r\n\r\n            <!-- PDF Viewer Component -->\r\n            <syncfusion:SfPdfViewer x:Name=\"PdfViewer\"\r\n                    ShowToolbars=\"False\"\r\n                    Grid.Row=\"1\"\r\n                    DocumentSource=\"{Binding DocumentStream}\"/>\r\n        </Grid>\r\n    </ContentPage.Content>\r\n</ContentPage>\r\n"
    },
    {
      "target": "src/components/pdf-viewer-text-search/PdfViewer.xaml.cs",
      "content": "namespace MAUI.Controls.PdfViewer.TextSearch\r\n{\r\n    public partial class PdfViewerView : ContentPage\r\n    {\r\n        TextSearchResult? SearchResult;\r\n        public PdfViewerView(PdfViewerViewModel viewModel)\r\n        {\r\n            InitializeComponent();\r\n            BindingContext = viewModel;\r\n\r\n            // Customize the highlight colors for search results.\r\n            PdfViewer.TextSearchSettings.CurrentMatchHighlightColor = Color.FromRgba(\"#8F00FF43\"); // Highlight color for the current match.\r\n            PdfViewer.TextSearchSettings.OtherMatchesHighlightColor = Color.FromRgba(\"#00FF0043\");  // Highlight color for other matches.\r\n        }\r\n        private void SearchButtonClicked(object sender, EventArgs e)\r\n        {\r\n            SearchText(\"the\");\r\n        }\r\n\r\n        // Searches for the specified text asynchronously and stores the result.\r\n        async void SearchText(string text)\r\n        {\r\n            PdfViewer.TextSearchProgress += PdfTextSearchProgress;\r\n            SearchResult = await PdfViewer.SearchTextAsync(text);\r\n        }\r\n\r\n        private void PdfTextSearchProgress(object? sender, TextSearchProgressEventArgs? e)\r\n        {\r\n            if (e != null)\r\n                // Cancel the search operation when it is running but does not need to be continued.\r\n                e.SearchResult?.Clear();\r\n        }\r\n\r\n        // Moves to the next match when the next button is clicked.\r\n        private void NextMatchButtonClicked(object sender, EventArgs e)\r\n        {\r\n            SearchResult?.GoToNextMatch();\r\n        }\r\n\r\n        // Moves to the previous match when the previous button is clicked.\r\n        private void PreviousMatchButtonClicked(object sender, EventArgs e)\r\n        {\r\n            SearchResult?.GoToPreviousMatch();\r\n        }\r\n\r\n        // Clears the search highlights and resets the search state.\r\n        private void CloseSearchButtonClicked(object sender, EventArgs e)\r\n        {\r\n            SearchResult?.Clear();\r\n        }\r\n    }\r\n}\r\n"
    }
  ]
}