niklasvh / html2canvas

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

HTML 2 Canvas issue on MacOS #3195

Open talhameer opened 1 month ago

talhameer commented 1 month ago

Please make sure you are testing with the latest release of html2canvas. Old versions are not supported and issues reported for them will be closed.

Please follow the general troubleshooting steps first:

Bug reports:

I'm creating HTML-to-PDF using this package. The HTML preview is perfect on all devices including Mac and Windows. But when I make a PDF, everything goes smoothly on Windows and all browsers. But on Mac, I face some issues related to image placement on MacBook when I make PDFs. On Safari, the image is not displayed. And on Google Chrome the image is zoomed and not positioned centered as it is previewed.

The following are the CSS styles that are being applied.

export const ImageWrapper = styled.div`
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: relative;
  aspect-ratio: 1 / 1;
  margin-bottom: 20px;

  img {
    position: absolute;
    width: 100%;
    height: auto;
  }
`;

Please let me know how I can fix this issue.

Specifications: