dompdf特殊字符 [英] dompdf special characters
问题描述
我已经成功完成了html到pdf的转换,但是没有特殊字符。
I'm having successful html-to-pdf conversions, but not with special characters.
下面只是我要显示的特殊字符,其中当我将其放在html文档中时,它就会显示在Mac的浏览器中。 (但不在我的Windows框上)
Below is just a special character I'm trying to display, which displays in browsers on my Mac, when I put it simply inside an html document. (but not on my windows box)
<?php
require_once("../dompdf_config.inc.php");
$html = '€';
$dompdf = new DOMPDF(); $html = iconv('UTF-8','Windows-1250',$html);
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("contract.pdf");
exit(0);
?>
我不断收到? (问号)何时渲染pdf。
我知道有很多关于特殊字符的问题,但是我想我可以尝试一下,并结合实际使用的代码。
I keep getting a "?" (question mark) when the pdf is rendered. I know there's been lots of issues documented with regards to special characters, but I thought I'd give this a try, with the code I'm actually using.
如果DomPdf不是推荐的html到pdf转换工具,我会提出其他建议!
If DomPdf isn't a recommended html-to-pdf conversion tool, I'll take any other recommendations!
推荐答案
在转换UTF-8 html页面时,我遇到了DOMPDF的问题。
我只是通过添加
I have experienced problems with DOMPDF when converting an UTF-8 html page. I simply solved the problem by adding
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
之间<头>标签。
如果您将其设置为编码类型,则可能是另一种选择。
Between < head > tag. Maybe it could be an alternative if you set it with your encoding type.
以下注释中的重要提示:在相同的pdf实例上使用 stream()和 output()方法。如果这样做,将无法正常工作。
IMPORTANT NOTE from comments below: don't use stream() and output() methods on the same pdf instance. If you do this wont work.
这篇关于dompdf特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!