1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| const style = document.createElement("style") document.head.appendChild(style) style.sheet?.insertRule("body > div:last-child img {display: inline-block}")
var shareContent = qrEl.value!; var width = shareContent.offsetWidth; var height = shareContent.offsetHeight; var canvas = document.createElement("canvas"); var scale = 1;
canvas.width = width * scale; canvas.height = height * scale; canvas.getContext("2d")!.scale(scale, scale);
const res = await htmlToCanvas(shareContent, { scale: scale, canvas: canvas, logging: true, width: width, height: height, useCORS: true, scrollX: 0, scrollY: 0 }) style.remove()
res.toBlob((blob) => { const url = URL.createObjectURL(blob!) window.open(url) })
|