Roderic
Roderic

Reputation: 11

Unable to set height of html2canvas

Configure the height of the generated canvas as follows , but the height of the actual generated canvas is the pixel height of the screen. I don't know why. Width also does not take effect

var opts = {
    logging: true,
    useCORS: true,  
    height:500,  
};

html2canvas(dom, opts).then(canvas =>{
    ...
})

Upvotes: 0

Views: 3031

Answers (1)

Roderic
Roderic

Reputation: 11

The problem is solved,directly pass a canvas with its own width and height.

var canvas = document.createElement('canvas');
canvas.width = 500;
canvas.height = 500;

var opts = {
    canvas : canvas,
    logging: true,
    useCORS: true, 
};

html2canvas(dom, opts).then(canvas =>{
    ...
})

Upvotes: 1

Related Questions