0
votes

I've been looking around the TCPDF docs (http://www.tcpdf.org/doc/code/classTCPDF.html) and can't find the solution to this issue anywhere.

How do I output a string on the PDF with mixed fonts? ie. let's say I want to output "hello world" but to have "hello" outputed using one font and "world" outputed other font.

I know how to do it in 2 different tries, ie. pick one font, echo 1 word, pick other font, echo other word. But is there a way to somehow do it all at once?

My issue is with echoing out centered HTML spans. I have 2 spans outputed using writeHTMLCell function where one span should be outputed using one font and the second one using the other font.

Can I maybe do this using TCPDF CSS?

Basically, I'm looking for a way to have centered text within a box with invisible borders, and 1 word of the text is outputed using 1 font / color, and the other word using other font / color.

Thanks!

EDIT: btw: I'm using custom font imported via addTTFfont function.

1
Normally I'd just recommend wkhtmltopdf here, but I have no idea how to do local-only fonts with it... - Charles
Yeah, my first idea was wkhtmltopdf too, but this seemed simpler.. And IMHO it is, but I can't find the solution to this problem anywhere in the docs because I have to preset the word style before echoing it, and by doing that - I can't have multiple words centered... - Andrej

1 Answers

0
votes

This anwser found on stackoverflow.com solved my issue => TCPDF Codeigniter use multiple fonts

Truns out custom fonts can be defined through CSS.