TCPDF
TCPDF copied to clipboard
TCPDF Showing Question Marks using Math symbols
Hi, I am facing issue in math symbols using tcpdf it showing ??? marks on pdf. is there any solution to handle it?
@muhammadazeemlums We had a similar problem, which we solved by using a TTF font that provides the glyphs for those characters. Be careful however, because you need a font with all the glyphs you want to be able to use, so it should not just cover misc symbols, it should also have your usual script (including possible diacritics etc.).
I didn't find such a font yet, but I admit I didn't spend a lot of time searching.
Once you have found the font, there are still a few possible hurdles:
- you don't just need one ttf file, but one for regular, one for bold, one for italic and one for bold italic (if you intend to use these variants).
- for each of the ttf files, you need to use
tools/tcpdf_addfont.php -i path/to/your/ttf/mycustomfont.ttf -o path/to/your/tcpdf/fonts/directory
, which generates sort of cache files that TCPDF requires to be able to use the font. You don't have to do that every time you generate a PDF, only once for each font. - once your files are there, in the script that generates your PDF, you can use TCPDF's method
AddFont('mycustomfont', '', 'path/to/your/tcpdf/fonts/directory/mycustomfont.ttf', 'default')
(as many times as you have variants: regular, bold, italic, bold italic…).
It would be really cool if TCPDF had a kind of fallback mechanism (i.e. when a glyph is not found using the current font, TCPDF looks up the character in another font that is more likely to have the corresponding glyph).