Redact PDFs
The steps to redact PDFs are as follows:
Create Redaction Annotations: A user applies to redact annotations that specify the pieces or regions of content that should be removed. This step marks the regions where redaction changes will be applied. These redaction annotations can be modified or deleted before applying redaction changes, without removing content from the document.
Apply Redaction Changes: After marking the areas for complete content removal, apply redaction changes. The content within the regions of the redaction annotations will be irreversibly deleted.
Through these two steps, you can thoroughly remove sensitive data from the document.
Create Redaction Annotations
You can use the addAnnotations
function to create redaction annotations.
Based on the function of ciphertext annotations, they can be divided into two types:
- Fill Black: After application, the marked area will be deleted and blacked out to clearly indicate that it contains sensitive information.
- Fill White: After application, the content of the marked area will be deleted, revealing the underlying color of the area. Regardless of the type of annotation applied, all content within the marked area will be completely deleted.
In addition, redaction annotations can be modified or deleted at this stage. Note that once redaction annotations have been applied, their appearance cannot be changed. This is because the redaction annotations will become non-editable, non-modifiable, static content instead of an interactive ciphertext annotation after it has been applied.
This sample shows how to create redaction annotations:
// create a redaction annotation to fill black.
docViewer.addAnnotations({
type: 'redact',
pageIndex: 0,
rect: {
left: 60,
top: 180,
right: 220,
bottom: 260
},
fillColor: 'rgb(0, 0, 0)',
erasure: false // When this attribute is not specified, the default value is false.
});
// create a redaction annotation to fill white.
docViewer.addAnnotations({
type: 'redact',
pageIndex: 0,
rect: {
left: 60,
top: 60,
right: 220,
bottom: 130
},
erasure: true
});
Apply Redaction Changes
The ComPDFKit SDK ensures that if text, images, or vector graphics are included in the region marked by a redaction annotation, the corresponding image or path data in that portion will be completely removed and cannot be restored.
Apply redaction annotations through the applyRedactions
function. Supported parameters:
- Annotation/Annotation List: Apply specified redaction annotations;
all
: All newly added redaction annotations in the application document annotations;- If no parameters are filled in, all newly added redaction annotations in the document annotations will be deleted.
This sample shows how to apply redaction annotations:
docViewer.applyRedactions('all');