TCPDF icon indicating copy to clipboard operation
TCPDF copied to clipboard

Tabulation not supported ?

Open BeressiLucas opened this issue 1 year ago • 2 comments

PHP => 8.2 TCPDF => 6.7.5 Symfony

Hello,

I wanted to create a PDF from text content generated by QuillJS, which I then converted using a Lexer. An example output looks like this:

<p>hello\t<\p>

In the output, we can see the tabulation character \t, but when generating the PDF, the tabulation is not respected. I’ve tried different code solutions, but none of them worked.

Solution Found: $html = str_replace("\t", str_repeat('&nbsp;', 4), $html);

This approach works for aligning the text correctly, except for the colons (:).

Example: This is what I expect the result to look like:

hello     :
hello1    :
ello2     :

However, the output I get is:

hello    :
hello1    :
ello2    :

I tried changing the font, but the alignment still breaks

I’ve tried using CSS methods like white-space and tab-index, but neither of them worked. We are using the Helvetica font and I don’t want to use a monospace font or the <pre> tag.

If anyone has any ideas, I’m open to suggestions! Thanks!

BeressiLucas avatar Feb 11 '25 12:02 BeressiLucas

Hello there, I'm having the same issue, any updates?

EnzoKilm avatar Nov 13 '25 14:11 EnzoKilm

Hello there, I'm having the same issue, any updates?

Making a pull request to fix it is the best way

williamdes avatar Nov 13 '25 18:11 williamdes