简体   繁体   中英

Convert a div to image without canvas

I need to generate an image with a corner ribbon, which musn't be an image since the text inside it changes. Once it's generated, I need the div (the image + the ribbon) to be saved as an image, but I'm not able to do it with html2canvas also because I don't have the images, I just have the link (and saving them would take too much time). Is there another method?

An answer to this similar question generated this interesting fiddle . I think that you could adapt this for your use.

It's essentually this javascript:

$(function() { 
    $("#btnSave").click(function() { 
        html2canvas($("#widget"), {
            onrendered: function(canvas) {
                theCanvas = canvas;
                canvas.toBlob(function(blob) {
                    saveAs(blob, "Dashboard.png"); 
                });
            }
        });
    });
});

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