tsayen / dom-to-image

Generates an image from a DOM node using HTML5 canvas
Other
10.21k stars 1.68k forks source link

image gets distorted when downloaded if zoomed in browser (safari) #479

Open nidhigoel-aq opened 1 month ago

nidhigoel-aq commented 1 month ago

Code

let chart_data = await domtoimage.toPng(document.getElementById('chart'), { width: clientwidth, height: container.clientHeight * scale, filter: (node: Node) => node !== action1 && node !== action2 && node !== action3 && node !== action4 && node !== action5 && node !== action7, style: { transform: 'scale(' + scale + ')' } } );

saveAs(chart_data, chartName + '.png');

Expected Image

expected

Safari image

safari

Issue

I use this code to save element as png. It works well on all browsers except when Safari is zoomed in. Some elements tend to shift while downloading in such a case.

Is there something I'm doing wrong?

No error in console.

Browsers

Safari version 17.5

forever0714yuan commented 1 month ago

你好,我已收到你的来信。辛苦了!!