简体   繁体   中英

Using JavaScript/html; how do I print a canvas outside of the print area?

I'm still new to javaScript. I created a canvas function and I'm able to print successfully, but how do I cater for a large canvas area. when I go to the further regions of the canvas and press print, it will print up to a point and ignore the rest. I tried creating a printCanvas that sets itself with the same paramaters as the canvas but it only prints the vertical part of the canvas not the horizontal part. The question is, how do I get to print the entire canvas?

I think you need to test (per browser) how it reacts on wrapping HTML DOM elements. For example; wrap a DIV-tag around the CANVAS-tag reserving the space you need. This will likely trigger the browser's print-layout to no ignore auto-sized objects. With that said also keep in mind to force fixed values as much as possible to fit the needs. This is not conform for web-rendering, but in your case that might prove useful.

<div style="height: 1600px; width: 900px;">
    <canvas height="1600" width="900">Not supported</canvas>
</div>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM