Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print preview #175

Closed
RobertasM opened this issue Nov 29, 2019 · 7 comments
Closed

Print preview #175

RobertasM opened this issue Nov 29, 2019 · 7 comments
Assignees
Labels
caused by a third-party lib This bug only happens when a certain third-party library is present. Or it's even a bug over there. documentation Solved

Comments

@RobertasM
Copy link

Hi,

I showing PDF viewer in modal it loads and shows pdf content, but when I try to print it opens print preview and nothing shown just empty pages. No errors in console. Maybe some ideas what can be wrong?

browser: chrome
angular version: 8.1.3
pdf viewer version: ngx-extended-pdf-viewer: 1.8.0-rc.1
image

@RobertasM
Copy link
Author

RobertasM commented Nov 29, 2019

After more debugging what I fount that in image this visible vertical line is a border style around PDF but somehow PDF self is hidden.

@stephanrauh
Copy link
Owner

Printing is always a pain with pdf.js. Cutting a long story short, it's almost always your CSS code. The PDF viewer generates the PDF pages as a hidden list of images at the end of the HTML document. A media query inverts visibility: everything is hidden except the images. As it turns out, there are many ways to break algorithm.

Funny thing is the vertical line. That's a new one. I don't have a clue where this comes from.

Please have a look at #170, #164, #152, and #148. They contain several bug patterns that may help you to debug and solve your issue.

Oh, and please tell me when you've managed to solve your bug. You can also send me a reproducer (i.e. a small but complete example running out-of-the-box without forcing me to install anything) if you're still struggling with the bug.

@stephanrauh stephanrauh self-assigned this Nov 30, 2019
@stephanrauh stephanrauh added the caused by a third-party lib This bug only happens when a certain third-party library is present. Or it's even a bug over there. label Nov 30, 2019
@RobertasM
Copy link
Author

RobertasM commented Dec 2, 2019

I see that images are inside div and if I change div to span or move from div then images are visible in print preview. Maybe you can comment more on why those images are inside div's and what CSS selection makes them visible when printing? Because I trying to find out which styles are getting overwritten. Also I using bootstrap 3.

@RobertasM
Copy link
Author

Found the issue and the fix is to override div style display to use inline like this:
@media print {
#printContainer > div {
display: inline;
}
}

@stephanrauh
Copy link
Owner

stephanrauh commented Dec 11, 2019

@RobertasM Awesome! I'll add your hint to the documentation.

@stephanrauh
Copy link
Owner

I've added the code snippet to https://pdfviewer.net/troubleshooting

@stephanrauh
Copy link
Owner

I've went over the print CSS again. When you update to version 9.0.0, your bugfix stops working. I believe you won't need the workaround once you've updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
caused by a third-party lib This bug only happens when a certain third-party library is present. Or it's even a bug over there. documentation Solved
Projects
None yet
Development

No branches or pull requests

2 participants