niklasvh / html2canvas

Screenshots with JavaScript
https://html2canvas.hertzen.com/
MIT License
30.5k stars 4.8k forks source link

[Issue] Canvas is pushed/cropped/cut #1613

Open denislapi opened 6 years ago

denislapi commented 6 years ago

Bug reports:

My canvas export is cut/moved/cropped. Seems like my element is pushed to the left so I can see the background of the canvas. My element has white color.

I tried to resolve the problem with {x: 0, y: 0} but then element which I want to convert to canvas is pushed to the middle of the canvas, so I can see the background color of canvas again. Screenshot: http://prntscr.com/kdbh0m

Screenshots: http://prntscr.com/kdb944, http://prntscr.com/kdb9fg

How it should look: http://prntscr.com/kdbbjl

1st screenshot: <canvas width="270" height="480" style="width: 1080px; height: 1920px;"></canvas>

2nd screenshot: <canvas width="270" height="480" style="width: 1080px; height: 1920px;"></canvas>

Implementation code:

html2canvas(template, {
  useCORS: true,
  widht: 1080,
  height: 1920,
  backgroundColor: "red"
  }).then(canvas => {
      html2canvasWrapper.appendChild(canvas);
  });

Detail

I noticed that this problem is repeated more often on Heroku then on localhost but I'm not sure if that is the problem. As I saw in the docs html2canvas is not dependent of the backend.

Specifications:

phanmn commented 4 years ago

Same issue