Tabulator character (\t) not printing with Roboto font in jsPDF

128 Views Asked by At

I have a solution using jsPDF where I generate a document dynamically based on user inputs. I have encounter that if the text to print contains the character \t everything that go after doesn't print in the PDF document.

Currently the PDF is using the font Roboto, in my tests I have found that without adding the Roboto font and use Helveltica for instance it prints ok by putting space between the words that contains \t between them, which I want but with the Roboto font.

I have tried as well to re-load a newer version from Google fonts, but not luck.

The following code should reproduce my problem (previously loaded the Roboto font):

var customText = '<p>This\tis\ta\ttest\tusing\ttab</p><p>This is a test using spaces</p>';
doc.setFont('roboto','normal');
doc.text(customText, 1, 10);

Output:

enter image description here

Expected output (with Roboto font, this one is the one by default):

enter image description here

Why might this happening with a custom font?

0

There are 0 best solutions below