Production-safe redaction workflow
Use this guide when your output must be legally sanitized and safe to share. The canonical sequence below ensures redactions are applied permanently before the final PDF is exported, so no underlying content remains in the file.
Do not allow final export before applyRedactions() succeeds when compliance or sanitization is required.
Canonical sequence
- Mark redactions (via UI tools or programmatically).
- Apply permanently with
instance.applyRedactions(). - Export final PDF only after step 2 succeeds.
Required toolbar tools (UI workflow)
To enable users to mark redactions in the UI, include one or both of the following toolbar items:
redact-text-highlighterfor text redactionsredact-rectanglefor area redactions
NutrientViewer.load({ container: "#nutrient-viewer", document: "/path/to/document.pdf", toolbarItems: [ ...NutrientViewer.defaultToolbarItems, { type: "redact-text-highlighter" }, { type: "redact-rectangle" } ]});Gate final export until permanent apply succeeds
To enforce the production-safe sequence, apply redactions directly in the final export action:
async function exportFinalPdf(instance) { await instance.applyRedactions(); return instance.exportPDF();}Export recommendation matrix
The following table summarizes the recommended export methods based on your final output goals:
| Goal | Recommended export | Notes |
|---|---|---|
| Final sanitized PDF after permanent redaction apply | exportPDF() | Default final export after applyRedactions() succeeds. |
| Final sanitized PDF + flatten remaining annotations for downstream compatibility | exportPDF({ flatten: true }) | Use when you also need non-redaction annotations/forms flattened in the exported PDF. |
Related guides
- Programmatically redact PDFs using JavaScript
- Redact PDFs using JavaScript tools
- Headless redaction
- Flatten annotations