{
  "$schema": "https://ai.syncfusion.com/schema/registry-item.json",
  "name": "pdf-viewer-redaction",
  "framework": "javascript",
  "type": "registry:component",
  "component": "PdfViewer",
  "variant": "redaction",
  "dependencies": [
    "@syncfusion/ej2-pdfviewer"
  ],
  "description": "PDF viewer sample marking sensitive regions or searched text for permanent redaction.",
  "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/javascript/llms.txt",
    "skillPack": "syncfusion/javascript-ui-components-skills",
    "docs": "https://ai.syncfusion.com/gallery/javascript/pdf-viewer-redaction.md"
  },
  "files": [
    {
      "target": "src/components/pdf-viewer-redaction/pdf-viewer.html",
      "content": "<div class=\"control-section redaction-sample\">\n    <div class=\"redaction-toolbar\" role=\"group\" aria-label=\"Redaction controls\">\n        <button id=\"addRedaction\" class=\"e-btn e-primary\" type=\"button\" disabled>Add Redaction</button>\n        <label for=\"redactionSearch\">Text to redact</label>\n        <input id=\"redactionSearch\" class=\"e-input\" type=\"search\" placeholder=\"Search PDF text\" disabled />\n        <button id=\"searchRedaction\" class=\"e-btn\" type=\"button\" disabled>Search &amp; Mark</button>\n        <button id=\"applyRedactions\" class=\"e-btn e-danger\" type=\"button\" disabled>Apply Redactions</button>\n    </div>\n    <p id=\"redactionStatus\" class=\"redaction-status\" role=\"status\">Loading PDF document...</p>\n    <div id=\"redaction-viewer\" style=\"height:640px; width:100%;\"></div>\n</div>\n<style>\n    .redaction-sample { padding: 8px; }\n    .redaction-toolbar { display:flex; flex-wrap:wrap; align-items:end; gap:12px; margin-bottom:8px; }\n    .redaction-toolbar label { font-weight:600; margin-left:4px; }\n    .redaction-toolbar input { width:220px; }\n    .redaction-status { min-height:20px; margin:4px 0 10px; }\n    @media (max-width: 720px) {\n        .redaction-toolbar input { width:100%; }\n        .redaction-toolbar label { width:100%; margin-left:0; }\n    }\n</style>\n"
    },
    {
      "target": "src/components/pdf-viewer-redaction/pdf-viewer.ts",
      "content": "import {\n    Annotation, BookmarkView, FormDesigner, FormFields, LinkAnnotation, Magnification,\n    Navigation, PageOrganizer, PdfViewer, Print, TextSearch, TextSelection, ThumbnailView, Toolbar\n} from '@syncfusion/ej2-pdfviewer';\nimport type { RedactionSettings } from '@syncfusion/ej2-pdfviewer';\n\nPdfViewer.Inject(\n    Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView, ThumbnailView,\n    Print, TextSelection, TextSearch, Annotation, FormFields, FormDesigner, PageOrganizer\n);\n\nexport function initPdfViewerRedaction(): void {\n    let isApplyingRedactions = false;\n    let isDocumentLoaded = false;\n    let isSearching = false;\n    const viewer = new PdfViewer({\n        documentPath: 'https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf',\n        resourceUrl: 'https://cdn.syncfusion.com/ej2/35.1.37/dist/ej2-pdfviewer-lib',\n        isExtractText: true,\n        toolbarSettings: {\n            showTooltip: true,\n            toolbarItems: [\n                'OpenOption', 'UndoRedoTool', 'PageNavigationTool', 'MagnificationTool',\n                'PanTool', 'SelectionTool', 'CommentTool', 'SubmitForm', 'AnnotationEditTool',\n                'RedactionEditTool', 'FormDesignerEditTool', 'SearchOption', 'PrintOption',\n                'DownloadOption'\n            ]\n        }\n    });\n    const addButton = document.getElementById('addRedaction') as HTMLButtonElement;\n    const searchInput = document.getElementById('redactionSearch') as HTMLInputElement;\n    const searchButton = document.getElementById('searchRedaction') as HTMLButtonElement;\n    const applyButton = document.getElementById('applyRedactions') as HTMLButtonElement;\n    const status = document.getElementById('redactionStatus') as HTMLElement;\n\n    const updateControls = (): void => {\n        addButton.disabled = !isDocumentLoaded;\n        searchInput.disabled = !isDocumentLoaded || isSearching;\n        searchButton.disabled = !isDocumentLoaded || isSearching;\n        applyButton.disabled = !isDocumentLoaded;\n    };\n\n    viewer.documentLoad = (): void => {\n        viewer.toolbar.showRedactionToolbar(true);\n        isDocumentLoaded = true;\n        status.textContent = isApplyingRedactions\n            ? 'Redactions applied to the document.'\n            : 'Document loaded. Add a redaction or search for text to mark.';\n        isApplyingRedactions = false;\n        updateControls();\n    };\n\n    addButton.addEventListener('click', (): void => {\n        viewer.annotation.addAnnotation('Redaction', {\n            bound: { x: 150, y: 400, width: 200, height: 40 },\n            pageNumber: viewer.currentPageNumber,\n            overlayText: 'Confidential',\n            fillColor: '#000000',\n            fontColor: '#FFFFFF'\n        } as RedactionSettings);\n        status.textContent = 'Redaction added to the current page. Apply Redactions to make it permanent.';\n    });\n\n    searchButton.addEventListener('click', async (): Promise<void> => {\n        const term = searchInput.value.trim();\n        if (!term) {\n            status.textContent = 'Enter text to search for and redact.';\n            return;\n        }\n\n        isSearching = true;\n        updateControls();\n        status.textContent = `Searching for \"${term}\"...`;\n        try {\n            const results = await viewer.textSearchModule.findTextAsync(term, false);\n            let redactionCount = 0;\n            for (const result of results) {\n                if (typeof result.pageIndex !== 'number' || !result.bounds?.length) {\n                    continue;\n                }\n                for (const bound of result.bounds) {\n                    viewer.annotation.addAnnotation('Redaction', {\n                        bound: {\n                            x: bound.x * (96 / 72),\n                            y: bound.y * (96 / 72),\n                            width: bound.width * (96 / 72),\n                            height: bound.height * (96 / 72)\n                        },\n                        pageNumber: result.pageIndex + 1,\n                        overlayText: 'Confidential',\n                        fillColor: '#000000',\n                        fontColor: '#FFFFFF'\n                    } as RedactionSettings);\n                    redactionCount++;\n                }\n            }\n            status.textContent = redactionCount\n                ? `Marked ${redactionCount} match${redactionCount === 1 ? '' : 'es'} for \"${term}\". Apply Redactions to make them permanent.`\n                : `No matches found for \"${term}\".`;\n        } catch (error) {\n            console.error('Unable to search the PDF for redaction text.', error);\n            status.textContent = 'Unable to search the PDF. See the browser console for details.';\n        } finally {\n            isSearching = false;\n            updateControls();\n        }\n    });\n\n    applyButton.addEventListener('click', (): void => {\n        if (!window.confirm('Applying redactions permanently removes the marked content. Continue?')) {\n            status.textContent = 'Redaction application canceled.';\n            return;\n        }\n        isApplyingRedactions = true;\n        viewer.annotation.redact();\n        status.textContent = 'Applying redactions. The viewer will reload when processing is complete.';\n    });\n\n    viewer.appendTo('#redaction-viewer');\n    updateControls();\n}\n"
    }
  ]
}