Reputation: 1049
I'm using a pdf generator class(TCPDF) to generate a pdf file from some html. The problem is that that html text has some utf8 and unicode characters. This class has support for those characters.
I've made the settings and all works just fine on localhost. But when I upload the files to my web host, I get a white page. I use exacty the same code.
If I delete the unicode and utf-8 characters it works. I've copied the script but on the server it is not working. It is there a php setting for handling those characters? Something in php.ini maybe? Thank you
Upvotes: 1
Views: 603
Reputation: 2013
As well as making sure that PHP has the mbstring extension installed, make sure you're setting PHP's encoding in the script with mb_internal_encoding('UTF-8');
or in php.ini.
You also need to make sure that the font being specified in TCPDF has support for UTF-8 characters. I've had big problems with this over the years and eventually just decided to use the Freesans and Freeserif fonts that are bundled with TCPDF.
Also when instantiating the TCPDF class make sure you have set the 4th and 5th parameters of the class constructor. If omitted they should default to TRUE, UTF-8 but I always specify to make sure.
$pdf=new PDF('P', 'mm', 'A4', TRUE, 'UTF-8');
$pdf->SetPageOrientation('P', FALSE, $margin_v);
$pdf->SetMargins($margin_h, $margin_v, $margin_h, TRUE);
// USE BUNDLED freesans FONT FOR DECENT UTF-8 SUPPORT
$pdf->setFontSubsetting(TRUE);
$pdf->SetFont('freesans', '', 11);
Check the docs for the TCPDF constructor
Upvotes: 1