Image size rendered by html2canvas

0

I have a script that creates an image of a div using html2canvas and would like to know if there is any way to change the whidth and height of that image.

<div id="MinhaDiv">Conteúdo a ser renderizado</div>
<input id="Gerador" type="button" value="Gerar Imagem"/>
<div id="IMGfinal" ></div>

<script>
    $(document).ready(function(){
        var element = $("#MinhaDiv"); 

        $("#Gerador").on('click', function () {
            html2canvas(element, {
            onrendered: function (canvas) {
            $("#IMGfinal").append(canvas);
                }
            });
        });
</script>
    
asked by anonymous 29.04.2018 / 01:51

1 answer

1

The html2canvas documentation offers extra configuration options such as width and height , which can be declared in the function itself :

$(document).ready(function(){
    var element = $("#MinhaDiv"); 

    $("#Gerador").on('click', function () {
        html2canvas(element, { width: 500, height: 500,
        onrendered: function (canvas) {
        $("#IMGfinal").append(canvas);
            }
        });
    });
    
29.04.2018 / 02:57