The mergeDocument() function does not work

Which product are you using?
PDF.js Express Plus on an Angular 13 app

PDF.js Express Version
Original lib version was 7.3.0
Also tested with 7.3.9 and 8.7.0

Detailed description of issue
From : PDFJS Express WebViewer Class: Document
The mergeDocument() function does not work. The function is being called, but does nothing. The document stay unchanged and only contain the original file.
No error or warning printed in console.

Expected behaviour
We build the 1st document, then merge others in it, and then call the loadDocument() of the instance. The viewer should display all of the doc.

Does your issue happen with every document, or just one?
Every document

Code snippet

this.wvInstance.CoreControls.createDocument(this.piecesAttachees[0].file).then(async doc => {
            // Handle additional files
            for (const pieceAttachee of this.piecesAttachees.slice(1)) {
                await doc.mergeDocument(pieceAttachee.file);
            }

            this.wvInstance.loadDocument(doc, { fileName: this.piecesAttachees[0]?.file?.name, withCredentials: true });
        });

Hello, I’m Ron, an automated tech support bot :robot:

While you wait for one of our customer support representatives to get back to you, please check out some of these documentation pages:

Guides:APIs:Forums:

Share how you are using PDF.js Express in your organization you could win a $500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free. Learn more here

Hi Ytuzet,

I would recommend to be using version 8.7.0. There is a namespace change from 7 to 8 so it will look a little different.

this.wvInstance.Core.createDocument(this.piecesAttachees[0].file).then(async doc => {
            // Handle additional files
            for (const pieceAttachee of this.piecesAttachees.slice(1)) {
                await doc.mergeDocument(pieceAttachee.file);
            }

            this.wvInstance.UI.loadDocument(doc, { fileName: this.piecesAttachees[0]?.file?.name, withCredentials: true });
        });

Please try this sample.

Best Regards,
Zach Serviss
Web Development Support Engineer
PDFTron Systems, Inc.


Share how you are using PDF.js Express in your organization you could win a $500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free. Learn more here

Hi zserviss,

We’ve tested your solution with version 8.7.0 and same problem, the function mergeDocument() is being called, but does nothing :

const doc = await this.instance.Core.createDocument(file1);
await doc.mergeDocument(file2);
await this.instance.UI.loadDocument(doc, { fileName: 'file.pdf' });

We also noticed several other problems with pdfjs (that don’t exist with pdftron) :

  • we can’t merge (this issue)
  • blurry document
  • unopenable document (error message popup)
  • unreadable document (opened but truncated character)
  • zoom problem

Thanks for your feedback.

Best Regards

Hi Ytuzet,

Sorry for the miscommunication, PDF.js Express does not support document manipulation so mergeDocument will not work in express.

Please use PDFTron for document manipulation.

Best Regards,
Zach Serviss
Web Development Support Engineer
PDFTron Systems, Inc.


Share how you are using PDF.js Express in your organization you could win a $500 Amazon gift card. All participants will receive 6 months of PDF.js Express+ for free. Learn more here