# Using UI.printInBackground produces extra blank page in print preview

**URL:** <https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321>\
**Category:** Technical Support\
**Created:** [January 30, 2023, 2:59am UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321 "2023-01-30T02:59:15Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![goetzcj](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@goetzcj](https://pdfjs.community/u/goetzcj)\
**Post date:** [January 30, 2023, 2:59am UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/1 "2023-01-30T02:59:15Z")

</div>

**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  
});  
}

---

<div class="post-metadata">

**Author:** ![goetzcj](https://avatars.discourse-cdn.com/v4/letter/g/71c47a/32.png) [@goetzcj](https://pdfjs.community/u/goetzcj)\
**Post date:** [January 30, 2023, 2:57pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/2 "2023-01-30T14:57:19Z")

</div>

For a better description:

This happens when using Chrome and Brave.

This does not happen when using Edge or Firefox.

---

<div class="post-metadata">

**Author:** ![zserviss](https://avatars.discourse-cdn.com/v4/letter/z/a9a28c/32.png) [@zserviss](https://pdfjs.community/u/zserviss)\
**Post date:** [January 31, 2023, 10:52pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/3 "2023-01-31T22:52:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sam](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@sam](https://pdfjs.community/u/sam)\
**Post date:** [March 21, 2023, 3:11pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/4 "2023-03-21T15:11:37Z")

</div>

Do you have a status update for this one?

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [March 21, 2023, 9:03pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/5 "2023-03-21T21:03:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sam](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@sam](https://pdfjs.community/u/sam)\
**Post date:** [March 28, 2023, 7:06am UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/6 "2023-03-28T07:06:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [March 28, 2023, 10:26pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/7 "2023-03-28T22:26:07Z")

</div>

Hello sam,

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

Best regards,  
Tyler Gordon

---

<div class="post-metadata">

**Author:** ![sam](https://avatars.discourse-cdn.com/v4/letter/s/5f9b8f/32.png) [@sam](https://pdfjs.community/u/sam)\
**Post date:** [April 3, 2023, 12:49pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/8 "2023-04-03T12:49:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [April 3, 2023, 9:33pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/9 "2023-04-03T21:33:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![christoph.rosenbaum](https://avatars.discourse-cdn.com/v4/letter/c/6a8cbe/32.png) [@christoph.rosenbaum](https://pdfjs.community/u/christoph.rosenbaum)\
**Post date:** [April 19, 2023, 12:32pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/10 "2023-04-19T12:32:00Z")

</div>

Hi Tyler,

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

Cheers  
Christoph

---

<div class="post-metadata">

**Author:** ![wgolebi](https://avatars.discourse-cdn.com/v4/letter/w/59ef9b/32.png) [@wgolebi](https://pdfjs.community/u/wgolebi)\
**Post date:** [May 25, 2023, 8:38pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/11 "2023-05-25T20:38:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [May 30, 2023, 10:59pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/12 "2023-05-30T22:59:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![wgolebi](https://avatars.discourse-cdn.com/v4/letter/w/59ef9b/32.png) [@wgolebi](https://pdfjs.community/u/wgolebi)\
**Post date:** [May 31, 2023, 1:49pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/13 "2023-05-31T13:49:33Z")

</div>

thank you @tgordon !

---

<div class="post-metadata">

**Author:** ![tgordon](https://avatars.discourse-cdn.com/v4/letter/t/aca169/32.png) [@tgordon](https://pdfjs.community/u/tgordon)\
**Post date:** [June 13, 2023, 8:51pm UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/14 "2023-06-13T20:51:10Z")

</div>

Hey wgolebi,

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

Best regards,  
Tyler Gordon

---

<div class="post-metadata">

**Author:** ![christoph.rosenbaum](https://avatars.discourse-cdn.com/v4/letter/c/6a8cbe/32.png) [@christoph.rosenbaum](https://pdfjs.community/u/christoph.rosenbaum)\
**Post date:** [September 12, 2023, 9:28am UTC](https://pdfjs.community/t/using-ui-printinbackground-produces-extra-blank-page-in-print-preview/2321/15 "2023-09-12T09:28:08Z")

</div>

Hello Tyler,

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

 ![print](https://canada1.discourse-cdn.com/flex031/uploads/pdfjscommunity/original/2X/8/8416edb39478b64d32026f5750ad92df30b96d70.png)

Cherrs  
Christoph
