0

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
sashoalm
  • 75,001
  • 122
  • 434
  • 781
Nikolay
  • 1
  • 1
  • 1

1 Answers1

0

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.

Goran Rakic
  • 1,789
  • 15
  • 26
  • I get the next: `html_entity_decode() [function.html-entity-decode]: charset CP-1251' not supported, assuming iso-8859-1 in /var/www/myproject/parsingHTML.class.php on line 203` When I try "CP1251" or "cp1251" and etc. - it is again white spaces instead characters. Also, I was try use UTF-8 encoding and iconv function, in this case i get message from Acrobat Reader "PDF document is damaged". Any way thank you for answer. – Nikolay Apr 06 '11 at 13:47