Replies: 3 comments 2 replies
-
I'm not able to reproduce the issue. Could you please share your exact HTML? |
Beta Was this translation helpful? Give feedback.
-
I am also seeing this problem when printing a page containing any Chart canvas element. The page looks fine rendered to screen but when printed (or Save to PDF) in Chrome, it includes over 450 blank pages at the end. |
Beta Was this translation helpful? Give feedback.
-
I can say that I also see this issue with chart.js 2+ on the latest Chrome. All other browsers are OK, and very old versions of Chrome do work fine too. So this is probably due to an issue in Chrome, or maybe they fixed an issue that triggered an issue in this library. As @BenCant could tell us that chart.js 3+ doesn't has this issue. I could look into using that version to see if we stop seeing the issue too. |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have a Chart.js javascript chart placed on my web page.
The chart sits inside a Canvas element which has ID: chart-0
<canvas id="chart-0" height="380px"></canvas>
This canvas element is put inside a absolute div element with ID "Chart0" which has been put inside a parent/relative div element with ID "PrintArea".
When users click the "Print" button, javascript code which I wrote prints out the the div element "PrintArea" and its contents.
I was using the javascript code:
window.print();
to print the "PrintArea" div element containing the canvas element "chart-0" because this way, it could print out the Chart.js javascript chart as well as all other html contents inside the "PrintArea" div.
This web page was working fine, it was printing out the part of the web page ("PrintArea" div) without any problem for the last 4 years.
But recently, when users click the print button, the web browser is printing out the "PrintArea" div contents AS WELL AS printing out 715 blank web pages after it. This happens with both Chrome and Edge browsers.
I can see, the problem IS caused by the Chart.js canvas element because if I remove this Chart.js canvas element - "chart-0" from the web page, then the web browser only prints out the contents of the "PrintArea" without any errors.
So,... how do I fix this error? It looks like any webpages that I've created which contain Chart.js are now causing this sort of problem - printing out hundreds of blank pages, whether I use the web browser's default printing menu or javascript printing function.
Please help.
Beta Was this translation helpful? Give feedback.
All reactions