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

Hidden canvas not being printed #159

Closed
sprietNathanael opened this issue Aug 14, 2019 · 4 comments
Closed

Hidden canvas not being printed #159

sprietNathanael opened this issue Aug 14, 2019 · 4 comments
Labels

Comments

@sprietNathanael
Copy link

Hi!
I'm using your module to print custom components that are not displayed. I hide the component's container and pass the ref of the inner component. It works greatly, and allows me to make a print version of what is displayed.
I'm trying to print charts from chartjs lib. I put the chart in the inner component, but when I try to print, nothing happens and I got this error :

index.js:111 Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.
    at HTMLIFrameElement.f.onload (http://localhost:3000/static/js/0.chunk.js:300198:45)

Do you have any idea on how to print canvas elements that are not drawn?

@MatthewHerbst
Copy link
Owner

Hi there. Unfortunately I don't know much about drawing to the canvas, let alone a hidden one. This seems like it would find a wider audience if you asked it on StackOverflow. If you ask it there can you please link the question here so that we can see if anyone finds the answer? Thanks! Going to close this since it's not an issue directly with this library, but happy to continue the discussion if there's any input I can provide.

@MickaelNeves
Copy link

MickaelNeves commented May 27, 2020

instead of hiding the element with { display: 'none'; }, try using { overflow: hidden; height: 0; }

@petartonchev
Copy link

@MickaelNeves solution works perfectly. Thanks!

@adenta
Copy link

adenta commented Dec 22, 2020

Is this still the recommended solution? Can't say it's working in chrome on OSX for me

EDIT: Just kidding. For future viewers, I was having an issue with my refs being passed down the component tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants