How can I help you?
PdfRedactor
16 Mar 20262 minutes to read
Represents a content redactor from an existing PDF document.
let document: PdfDocument = new PdfDocument(data, password);
// Create a new text extractor
let redactor: PdfRedactor = new PdfRedactor(document);
// Add redactions to the collection
let redactions: PdfRedactionRegion[] = [];
redactions.push(new PdfRedactionRegion(0, {x: 10, y: 10, width: 100, height: 50}));
redactions.push(new PdfRedactionRegion(2, {x: 10, y: 10, width: 100, height: 50}, true, {r: 255, g: 0, b: 0}));
redactor.add(redactions);
// Apply redactions on the PDF document
redactor.redactSync();
// Save the document
document.save('output.pdf');
// Destroy the document
document.destroy();Methods
add
Add redactions with specified options.
| Parameter | Type | Description |
|---|---|---|
| redactions | PdfRedactionRegion[] |
An array of redaction objects to specify the page index, bounds and appearance of the redaction to be applied. |
Returns void
redact
Redacts all marked regions in the PDF document.
| Parameter | Type | Description |
|---|---|---|
| callBack | canvasRenderCallback |
A function that supplies a canvas element along with the current application platform.The canvas is used internally to render and redact image content. |
Returns Promise
redactSync
Redacts all marked regions in the PDF document synchronously.
This method removes text and vector content within the specified redaction regions. It does not support image redaction.To redact images inside the PDF, use the asynchronous redact() method instead.
Returns void