This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/web/redaction/headless.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Headless JavaScript PDF redaction library | Nutrient SDK

It’s possible to apply redaction operations without the need to present any user interface (UI) to the user.

Do not allow final export before applyRedactions() succeeds when compliance/sanitization is required.

Standalone

In Standalone mode of Nutrient Web SDK, you can perform the operation using JavaScript in the browser by setting the headless option as 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 is loaded, 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);
});