Redact feature in PDFJS


Is it possible to add any redact feature with thickness option in hand ?
If not then how can i use line feature as redact when i have to use line
in shape as well as redact seperately. I tried it but when i adjust redact line feature
thickness, it automatically select line in shape and sets same color and thickness of redact one because i am using same toolbutton (AnnotationCreateLine) for both.

So is there any work around for it?

Abhishek Maurya

Hey Abhishek,

PDF.js Express does not support redaction as it does not support any direct document manipulation.

Line annotations cannot be used as redactions because they can easily be removed, and do not actually remove content out of the PDF like a redaction does.

If you need full redaction support, you can check out our sister product, PDFTron Webviewer. It has the exact same API as Express but has many more features (such as redaction!)


Hi logan,
Actually in our implementation redaction means just to cover particular part in
pdf (with black thick line), and we can remove that line whenever we want.

Sorry for mentioning redact term but we doesn’t intent to implement exact redact feature.
We can say this as a hide feature. So could you please me how to solve
my above issue of implementing hide feature using line.

Abhishek Maurya

Just to be clear, you want to set the default thickness of the Line tool?

Hi logan,

yes i want to set the thickness of line tool which i am using in customized header
using its toolbutton. But it should not interfere with line thickness of line inside
shapes toolgroup,
which i guess means that we want another copy of line tool in the main
header whose line thickness can be adjusted without interfering the thickness of
line line tool inside shapes group.

Is it possible?



You can do this by following these steps:

  1. Create a new Line tool and register it in the UI
  2. Add a button in the header for it

Here is some sample code that should work for you:

  const newLineTool = new instance.Tools.LineCreateTool(instance.docViewer)
    StrokeThickness: '30pt'
    toolName: 'LineRedactTool',
    buttonName: 'LineRedactTool',
    toolObject: newLineTool,
    showColor: 'always',
    buttonImage: '<svg xmlns="" viewBox="0 0 24 24"><defs><style>.cls-1{fill:#abb0c4;}</style></defs><title>icon - tool - shape - line</title><rect class="cls-1" x="3" y="10.75" width="18" height="2.5" rx="0.6" transform="translate(-4.97 12) rotate(-45)"></rect></svg>'

  instance.setHeaderItems(header => {
    const items = header.getItems();
      type: 'toolButton',
      toolName: 'LineRedactTool'

The relevant APIs can be found below:

Hope this helps!

Thank you for the solution! it helps