0

i'm trying to capture an entire div which has some text over a background image that covers said div entirely. It works fine on desktop but on mobile, when i try to download it the background image doesn't show up at all instead the text is on a white background. here's my code for dom-to-image:

const saveDivAsImage = (target) => {
    const scale = 3;

    const style = {
      transform: "scale(" + scale + ")",
      transformOrigin: "top left",
      width: target.offsetWidth + "px",
      height: target.offsetHeight + "px",
    };

    const param = {
      height: target.offsetHeight * scale,
      width: target.offsetWidth * scale,
      quality: 1,
      style,
    };
    setTimeout(() => {
      domToImage.toPng(target, param).then((dataUrl) => {
        const link = document.createElement("a");
        link.download = "image.png";
        link.href = dataUrl;
        link.click();
      });
    }, 3000);
  };

i tried adding a timeout but it did nothing...

queercoded
  • 55
  • 9

0 Answers0