html2pdf.js icon indicating copy to clipboard operation
html2pdf.js copied to clipboard

Add a new Test with Table and content.

Open cablegunmaster opened this issue 7 years ago • 2 comments

A pull request for a new test containing a table and some LOREM IPSUM.

Why I think this is a good test case? Because in IE the text overlapses and collapses upon itself.

When does this happen? This happens in IE 11 and Edge: the text goes over the other line and ignores the beginning part.

Findings:

  • The textLine is collapsed too early.
  • The textline is not detecting the linebreak and writes text over it.

Sidenote:

  • In FF and in Chrome it works as intended.
  • tested in v0.91

IE and edge: image

Chrome and FF example: image

cablegunmaster avatar Nov 19 '18 15:11 cablegunmaster

Hi @cablegunmaster, thanks for the contribution and sorry it took a while. To answer: this is an issue in html2canvas, and it's related to your use of white-space: pre. I've copied your code into a Fiddle and made a couple changes: https://jsfiddle.net/eKoopmans/t1zxomac/

  1. Added the html2canvas library on its own.
  2. Added a "Generate Canvas" button, which attaches a canvas to the bottom of the page.
  3. Removed the white-space: pre style from the first <tr>, but not on the second.

You'll see that in IE, the first block of text looks fine, and the second doesn't. Same results in the canvas as in the PDF.

I can't answer why - have a look on the html2canvas issues and see if anything turns up. One common solution to problems like this is to use the html2canvas option letterRendering: true, you could give that a shot. And if you can't find a matching issue, please open one over there about this problem (though see if you can boil down your example to be as simple as possible). Good luck!

I won't merge this test in as it's revealing an error in html2canvas, not in html2pdf, but thanks for raising the issue.

eKoopmans avatar Jan 27 '19 04:01 eKoopmans

nice

eriko20 avatar Aug 09 '22 02:08 eriko20