stephanrauh / ngx-extended-pdf-viewer

A full-blown PDF viewer for Angular 16, 17, and beyond
https://pdfviewer.net
Apache License 2.0
486 stars 184 forks source link

Print view adds an additional blank page #1318

Closed 1nutzername closed 2 years ago

1nutzername commented 2 years ago

Describe the bug The print view adds an additional blank page.

Version info

Desktop (please complete the following information):

To Reproduce I created a demo project with Angular 12 and latest version 12 of the viewer: Demo repo

Just click the Button to activate the viewer and the printing screen.

Screenshots grafik

Thanks a lot for having a look :)

BR i7i5

stephanrauh commented 2 years ago

Thanks for providing a reproducer!

stephanrauh commented 2 years ago

When you open your file on https://pdfviewer.net/extended-pdf-viewer/simple, there's no extra page in the print preview. I haven't seen the offending CSS rule yet, but judging from previous error reports, I'm 95% sure it's a CSS problem hidden somewhere in your project.

stephanrauh commented 2 years ago

I'm confused. I've counted the CSS rules of your project. I ended up with zero. Adding insult to injury, I can reproduce the extra page with a fresh project (ng new + ng add ngx-extended-pdf-viewer).

stephanrauh commented 2 years ago

As it turns out, the additional page seems to be caused of the width of your demo document. It seems to be a tiny fraction too wide. I've added this rule to the global styles.css, and it solves the problem:

body[data-pdfjsprinting] #printContainer>.printedPage {
  width: 99.99% !important;
}
1nutzername commented 2 years ago

Hello, I tested this solution in our production code and it works flawless. Thanks a lot for investigation! :)