Reputation: 1
I was download and setup script from:http://www.html2pdf.fr/en It works fine with default encoding, but when I try to generate docs with characters in CP-1251, I got white spaces instead of characters. Also All my files in CP-1251,data in base in CP-1251 and as you can see I use simple font -Arial
Please, maybe exist some solution to get it to work.
P/s sorry for my english
ob_start();
include(dirname(__FILE__).'/res/exemple00.php');
$content = ob_get_clean();
require_once(dirname(__FILE__).'/../html2pdf.class.php');
try
{
$html2pdf = new HTML2PDF('P','A4','fr');
$html2pdf->setDefaultFont('Arial');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
$content1=$html2pdf->Output('', 'S');
// Some php code
$db->query("set names cp1251");
$query="SELECT data from files Where id=$file_id ";
$result=$db->query($query);
$row=$result->fetch_assoc();
$content=($row['data']);
header('Content-Type: application/pdf');
header("Content-Length: ".strlen(content));
header('Content-Disposition: attachment; filename=Invoice#'.$invoice_id.'.pdf');
print $content;
}
catch(HTML2PDF_exception $e) { echo $e; } enter code here
Upvotes: 0
Views: 6980
Reputation: 1799
I am not using this library, but are you setting your encoding in the HTML2PDF constructor?
$html2pdf = new HTML2PDF('P','A4','fr', true, 'CP-1251');
If it does not work, try 'cp1251' or 'CP1251', I do not find list of recognized encodings in the documentation. You can also use iconv and convert to UTF-8 as it seems to be a default.
Upvotes: 0