简体   繁体   中英

Printing Div to PNG with html2canvas with background images

I am using html2canvas plugin to print a div to png format. Till now, I can print div to png but background images are missing.

My html2canvas jquery code is

 html2canvas($(".comp-card-wrapper"), {
     onrendered: function (canvas) {
         // canvas is the final rendered <canvas> element
         var myImage = canvas.toDataURL("image/png");
         window.open(myImage);
     }
 });

Full code is on JsFiddle at http://jsfiddle.net/j2mpetdz/1/ Please if anyone have any idea, what I am missing, it would be a great help.

This appears to be a known bug that will be fixed in html2canvas version 0.5.0. However that version is still not available for use.

Have a look at this answer for a possible work-around (which seems compatible with future version 0.5.0RC).

Hope this helps!

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