Using UI.printInBackground produces extra blank page in print preview

Which product are you using?
PDF.js Express Viewer

PDF.js Express Version
8.7

Detailed description of issue
When rendering the pdf in the viewer, all pages are correct (without a blank page at the end). When utilizing the instance.UI.printInBackground function, the print preview in Chrome (latest version) shows the document plus a blank page added to the end. It will also print that page if it goes unnoticed.

Expected behaviour
Document rendered to the viewer and in the print preview should have the same number of pages and not have a blank page added to the end.

Does your issue happen with every document, or just one?
Happens on all documents

Link to document
Not possible at the moment.

Code snippet
UI.setHeaderItems(header => {
header.push({
type: ‘actionButton’,
img: ‘icon-header-print-line’,
onClick: () => {
printCurrentDocument();
}
});
});

function printCurrentDocument() {
instance.UI.printInBackground({
includeComments: false,
includeAnnotations: false,
maintainPageOrientation: true
});
}

1 Like

For a better description:

This happens when using Chrome and Brave.

This does not happen when using Edge or Firefox.

Hi @goetzcj,

We are currently working on this and will let you know when it is fixed.

Best Regards,
Zach Serviss
Platform Support Engineer
PDFTron Systems, Inc.

Do you have a status update for this one?

Hi Sam,

We have a potential fix that was merged, can you try on 8.7.1?

If not we will have to make another release on March 29th.

Best regards,
Tyler

Hi Tyler, we were already running 8.7.1 and unfortunately the problem still remains.

Hello sam,

Thanks for letting me know, I will ensure the fix is included in tomorrow’s release.

Best regards,
Tyler Gordon

Hi Tyler, with 8.7.2 this seems fixed for pdf’s with more than 1 page. If you have exactly 1, the issue still persists.

Edit: only reproducible on Firefox, Chrome seems fine now.

Hello sam,

I tried with a blank document with only 1 page and it printed only the 1 page.

Can you provide a document you tested with?

Best regards,
Tyler

Hi Tyler,

i have the same Problem with One Page PDF Documents, is also reproducible.

Cheers
Christoph

hi @tgordon
I’m running into this issue. I’m using v8.7.3 and I’m seeing an extra blank page in the the print preview. I’m opening a pdf that has 2 pages and seeing 3 pages (including the blank one).
Is there any fix for this? It only works fine in FireFox.

Hi wgolebi,

We have discovered this is due to a CSS issue from a recent Chrome update.

We will provide an update soon to fix this issue.

Best regards,
Tyler

thank you @tgordon !

Hey wgolebi,

Were looking to release v8.7.4 that will include this fix. Thank you for your patience!

Best regards,
Tyler Gordon

1 Like

Hello Tyler,

the Problem still exsits in Firefox 117, we used the last Version!

Cherrs
Christoph