Protecting confidential data using the redact annotation.

This example demonstrates how to use the Redact annotation feature to remove sensitive information from a PDF document. It contains confidential details, such as a name, address, phone number, and financial data, with a specific region marked for redaction. Users can apply the Redact annotation to this region and finalize the redaction using the "Apply All Redacts" button in the PDF viewer toolbar.

The demo is being dynamically compiled to support real-time code editing... For quicker access to features, switch to the "JavaScript" tab for a smoother experience! :)
app.js
index.html
styles.css
loading...
window.onload = function(){ const viewer = new DsPdfViewer("#viewer", { workerSrc: "/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.worker.js", supportApi: getSupportApiSettings() }); viewer.addDefaultPanels(); viewer.addAnnotationEditorPanel(); // Configure toolbar buttons: viewer.toolbarLayout.viewer = { default: ["save", "edit-redact", "edit-redact-apply", "$navigation", "$split", "text-selection", "pan", "$zoom", "$fullscreen", "doc-properties", "about"], mobile: ["save", "edit-redact", "edit-redact-apply", "$navigation", "$split", "text-selection", "pan", "$zoom", "$fullscreen", "doc-properties", "about"], fullscreen: ["$fullscreen", "save", "edit-redact", "edit-redact-apply", "$navigation", "$split", "text-selection", "pan", "$zoom", "doc-properties", "about"] }; viewer.toolbarLayout.annotationEditor = { default: ["edit-select","$split","edit-redact", "edit-redact-apply","$split", "edit-undo","edit-redo","save"], mobile: ["edit-select","$split","edit-redact", "edit-redact-apply","$split", "edit-undo","edit-redo","save"], fullscreen: ["$fullscreen", "edit-select","$split","edit-redact", "edit-redact-apply","$split", "edit-undo","edit-redo","save"] }; viewer.applyToolbarLayout(); viewer.layoutMode = 1; viewer.open("/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/pdf/confidential_redact_demo.pdf"); }
window.onload = function(){ const viewer = new DsPdfViewer("#viewer", { workerSrc: "/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.worker.js", supportApi: getSupportApiSettings() }); viewer.addDefaultPanels(); viewer.addAnnotationEditorPanel(); // Configure toolbar buttons: viewer.toolbarLayout.viewer = { default: ["save", "edit-redact", "edit-redact-apply", "$navigation", "$split", "text-selection", "pan", "$zoom", "$fullscreen", "doc-properties", "about"], mobile: ["save", "edit-redact", "edit-redact-apply", "$navigation", "$split", "text-selection", "pan", "$zoom", "$fullscreen", "doc-properties", "about"], fullscreen: ["$fullscreen", "save", "edit-redact", "edit-redact-apply", "$navigation", "$split", "text-selection", "pan", "$zoom", "doc-properties", "about"] }; viewer.toolbarLayout.annotationEditor = { default: ["edit-select","$split","edit-redact", "edit-redact-apply","$split", "edit-undo","edit-redo","save"], mobile: ["edit-select","$split","edit-redact", "edit-redact-apply","$split", "edit-undo","edit-redo","save"], fullscreen: ["$fullscreen", "edit-select","$split","edit-redact", "edit-redact-apply","$split", "edit-undo","edit-redo","save"] }; viewer.applyToolbarLayout(); viewer.layoutMode = 1; viewer.open("/document-solutions/javascript-pdf-viewer/demos/product-bundles/assets/pdf/confidential_redact_demo.pdf"); }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <title>Protecting confidential data using the redact annotation</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" href="./src/styles.css"> <script src="/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/dspdfviewer.js"></script> <script src="/document-solutions/javascript-pdf-viewer/demos/product-bundles/build/wasmSupportApi.js"></script> <script src="/document-solutions/javascript-pdf-viewer/demos/resource/js/init.js"></script> <script src="./src/app.js"></script> </head> <body> <div id="viewer"></div> </body> </html>
#viewer { height: 100%; }