0

我是从以下网址下载和设置脚本的:http://www.html2pdf.fr/en 它在默认编码下工作正常,但是当我尝试使用 CP-1251 中的字符生成文档时,我得到的是空格而不是字符。还有我在 CP-1251 中的所有文件,CP-1251 中的基础数据,正如你所看到的,我使用简单的字体 -Arial

请,也许存在一些解决方案来让它工作。

P/s 对不起我的英语

    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');

// 一些php代码

    $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("内容长度:".strlen(content));

header('Content-Disposition: attachment; filename=Invoice#'.$invoice_id.'.pdf');

打印$内容;

}

catch(HTML2PDF_exception $e) { echo $e; }    enter code here
4

1 回答 1

0

我没有使用这个库,但是您是否在 HTML2PDF 构造函数中设置了编码?

    $html2pdf = new HTML2PDF('P','A4','fr', true, 'CP-1251');

如果它不起作用,请尝试“cp1251”或“CP1251”,我在文档中找不到可识别编码的列表。您还可以使用 iconv 并转换为 UTF-8,因为它似乎是默认设置。

于 2011-04-05T18:11:44.380 回答