niklasvh / html2canvas

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

Text overlapping in chrome latest version on using html2canvas javascript library #3194

Open nishant-appvent opened 2 months ago

nishant-appvent commented 2 months ago

363686157-bb109689-7cf5-4068-bb86-a0770784d5f0 The actual correct HtmlElement

363686266-6abffc22-5e4c-49bc-923d-1f46f0374d33 The image after converting it through html2canvas version "^1.4.1".

KnvMmi9G image on commenting this code in node_modules. var segmentWords = function (value, styles) { // if (FEATURES.SUPPORT_NATIVE_TEXT_SEGMENTATION) { // // eslint-disable-next-line @typescript-eslint/no-explicit-any // var segmenter = new Intl.Segmenter(void 0, { // granularity: 'word' // }); // // eslint-disable-next-line @typescript-eslint/no-explicit-any // return Array.from(segmenter.segment(value)).map(function (segment) { return segment.segment; }); // } return breakWords(value, styles); };

Bug reports:

I am facing this issue in latest chrome version i.e. 128.0.6613.84. While it was working fine with chrome version 127.0.6533.119. Can any one please suggest any solution for this? Can you please look into it, @niklasvh?

Specifications:

suddath-somani commented 2 months ago

Facing the same issue. We are using jspdf to convert static html template to pdf, jsPdf internally uses html2canvas for this conversion. Everything was working fine before, but now after chrome v-128 update, the generated pdf seems to break.

sample_jspdfpng

Can anyone suggest an alternative library to convert static html to pdf?

Note: The html to be downloaded is not being rendered, so the alternative should be able to handle the conversion without rendering.

nishant-appvent commented 2 months ago

We fixed this by removing "zoom" css property from that element. Have a look at this chrome release note, We were also facing this on using scale so we removed it.

suddath-somani commented 2 months ago

Yes i figured. Our application's layout is structured as such that it is not possible to remove zoom property at this point.