Headless redaction
You can apply redaction operations without presenting any user interface (UI) to the user.
Don’t allow final export before applyRedactions() succeeds when compliance/sanitization is required.
Standalone
In standalone mode of Nutrient Web SDK, you perform the operation using JavaScript in the browser. Set the headless option to true when loading the JavaScript library. This indicates you don’t want a UI:
NutrientViewer.load({ // ... headless: true}).then((instance) => { // Apply your operations.}).catch((error) => { console.error("Failed to load viewer:", error.message);});Once the SDK loads, you can apply any of our operations as normal.
Server-backed
When using the server-backed operational mode, a variety of operations are available server-side. Refer to the Document Engine documentation for additional information.
Complete headless example
Redact all Social Security numbers without showing the UI.
For export behavior recommendations (exportPDF() vs. exportPDF({ flatten: true })) and finalization sequencing, refer to the production-safe redaction workflow guide.
NutrientViewer.load({ document: "document.pdf", headless: true}) .then(async (instance) => { // Search and create redaction annotations. const ids = await instance.createRedactionsBySearch( NutrientViewer.SearchPattern.SOCIAL_SECURITY_NUMBER, { searchType: NutrientViewer.SearchType.PRESET } );
if (ids.length > 0) { console.log(`Found ${ids.length} SSNs to redact`); await instance.applyRedactions(); const pdf = await instance.exportPDF(); // Save or send the redacted PDF. } else { console.log("No SSNs found in document"); } }) .catch((error) => { console.error("Redaction failed:", error.message); });