Help with Custom Rectangle tool button

Detailed description of issue
I get this error while selecting the custom rectangle tool. I am using this as an redaction alternative by using the rectangle tool and filling it with black color and the redaction takes place using the PDFViewer API in the backend.

Expected behaviour
{Provide a screenshot or description of the expected behaviour}

Link to document
{Provide a link to the document in question if possible}

Code snippet
const { Tools, Annotations } = instance;

    const newRectangleTool = new Tools.RectangleCreateTool(



      FillColor: new Annotations.Color(0, 0, 0),

      StrokeThickness: "30pt",



      toolName: "RedactTool",

      buttonName: "RedactTool",

      toolObject: newRectangleTool,

      showColor: "always",

      tooltip: "Redact",

      buttonImage: "",

    instance.setHeaderItems((header) => {

      const items = header.getItems();

      items[items.length - 1] = {

        type: "toolButton",

        toolName: "RedactTool",




Could you please send us the document you are trying to open that is causing this error? Thanks

Here is the document.file-example_PDF_1MB.pdf (1017.7 KB)

Hi there,

I cannot reproduce your issue. You can provide the code you are using to load PDF.js Express. It sounds like there is a file that is missing and cannot be loaded. You could also check the console for any 404s.


I checkded the console there are no 404s,
Heres’ the code I use to load PDF.Js Express,
this.webViewerInstance = WebViewer(
path: “…/lib/public”,
//initialDoc: “…/files/webviewer-demo-annotated.pdf”,
config: “…/assets/myConfig.js”,
Here’s the folder structure for lib folder


I’m still not sure what is going on.

Would you be able to create a minimal example project where you can reproduce the error and send it to me? You could even just zip up your current project and send it.


Hi there!

Just following up on this issue. We were finally able to reproduce the issue and found that it is caused by calling loadDocument in rapid succession. This will be fixed in a future patch, but for now please make sure you aren’t calling loadDocument more than intended.