我找不到用于设置"DOMPDF_UNICODE_ENABLED"的dompdf_config.inc.php或dompdf_config.custom.inc.php.真的 [英] I Can't Find dompdf_config.inc.php or dompdf_config.custom.inc.php for setting "DOMPDF_UNICODE_ENABLED" true

查看:118
本文介绍了我找不到用于设置"DOMPDF_UNICODE_ENABLED"的dompdf_config.inc.php或dompdf_config.custom.inc.php.真的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用dompdf通过php将html页面另存为pdf.我在html页面(实际上是php页面)中使用了波斯字符,但是当我尝试将其另存为pdf时,导出看起来就像'?????'. :(..我搜索了所有网络,并发现了Unicode字符的配置 https://github.com/dompdf/dompdf/wiki/UnicodeHowTo#configure-dompdf-for-unicode-support "dompdf_config.custom.inc.php" 文件.但是问题是我无法在我的所有dompdf文件夹和所有文件系统中找到这样的文件.请有人告诉我它在哪里或我必须要做的是,由于其与CSS的出色兼容性,我必须使用dompdf.

这是导出. http://i.stack.imgur.com/nYAzW.png

这是我的代码.

I use dompdf to save a html page as pdf by php. I use Persian characters in my html page (actually php page) but when i'm trying to save it as pdf, the export just looked like '?????' :( .I have searched all the net and I found a configuration for unicode characters https://github.com/dompdf/dompdf/wiki/UnicodeHowTo#configure-dompdf-for-unicode-support in "dompdf_config.inc.php" or "dompdf_config.custom.inc.php" file. but the problem is I CAN'T FIND such file in all of my dompdf folder and in all of my file system. Please somebody tell me where it is or what I must do. something else is that I have to use dompdf because of its fantastic CSS compatibility. Thanks.

This is Export. http://i.stack.imgur.com/nYAzW.png

This is my code.

require("dompdf/autoload.inc.php");
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->loadHtml("<html><head>
<meta http-equiv=\"Content-Type\" content=\"text/html;charset=utf-8\">

<link rel=\"stylesheet\" type=\"text/css\" href=\"styles/scorestyle.css\">

</head>
<body><div>
<div id=\"showscorediv\"><table><tbody><tr class=\"scoresubject\"><th colspan=\"2\">کارنامه ارزیابی</th></tr><tr class=\"scorecategory\"><th>شاخص ها</th><th>امیتاز ها</th></tr><tr><td><span class=\"level_0\">شاخص های کیفی</span></td><td class=\"scoretd\">62</td></tr><tr><td><span class=\"level_1\">شاخص های مرتبط با تیم کاری</span></td><td class=\"scoretd\">10</td></tr><tr><td><span class=\"level_1\">شاخص های مرتبط با محصول</span></td><td class=\"scoretd\">28</td></tr><tr><td><span class=\"level_1\">شاخص های مرتبط با بازار</span></td><td class=\"scoretd\">24</td></tr><tr><td><span class=\"level_0\">شاخص های کمی</span></td><td class=\"scoretd\">60</td></tr><tr><td><span class=\"level_1\">شاخص های تولیدی</span></td><td class=\"scoretd\">20</td></tr><tr><td><span class=\"level_1\">شاخص های درآمدی</span></td><td class=\"scoretd\">14</td></tr><tr><td><span class=\"level_1\">شاخص های هزینه ای</span></td><td class=\"scoretd\">26</td></tr><tr class=\"scoresubject\"><th>امتیاز کل</th><th>122</th></tr></tbody></table>
</div>
</div></body></html>");
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream();

推荐答案

您似乎正在使用dompdf 0.7.0,该文件不再使用dompdf_config.inc.php配置文件.此版本始终启用Unicode支持.

You appear to be using dompdf 0.7.0, which no longer uses the dompdf_config.inc.php configuration file. Unicode support is always enabled with this release.

要显示示例代码中使用的字符,您需要确保:

To display the characters used in your sample code you need to ensure that:

  1. 您正在提供支持这些字符的字体(
  1. You are supplying a font that supports these characters (that appears to be the case).
  2. That dompdf has both read and write capability to the temporary directory, font directory, and font cache directory. You can set these using $dompdf->set_option('option', 'value'); (where option would be tempDir, fontDir, or fontCache).
  3. The font is accessible to dompdf and is in TTF format.
  4. You are correctly styling your content to use your font. Hard to know without seeing your CSS.

仅供参考,您不能只将TTF/UFM放到字体目录中. dompdf必须记录有关字体的信息才能使用它.同样,AFM指标文件在这种情况下也将无法工作,因为这表示字体上的Windows ANSI编码. Windows ANSI编码不支持示例中的字符. Dompdf将UFM指标格式用于Unicode支持.

FYI, you can't just drop the TTF/UFM in your font directory. dompdf has to record information about the font in order to use it. Also, the AFM metrics file won't work in this case anyway because that indicates Windows ANSI encoding on the font. Windows ANSI encoding does not support the characters in your sample. Dompdf uses the UFM metrics format for Unicode support.

早期版本的dompdf中包含的实用程序不再包含在0.7.0中.只要满足使用@font-face声明的要求,就不需要任何外部实用程序.但是,如果需要,您可以在 dompdf-utils项目.

The utilities that were included with previous versions of dompdf are no longer included with 0.7.0. So long as you meet the requirements of using the @font-face declaration you don't need any external utilities. If needed, however, you can find a compatible version of the load_font.php script in the dompdf-utils project.

由于您使用的是0.7.0(刚刚发布),因此Internet上的许多信息可能已过时,因此您可能想了解如何使用它:

Since you are using 0.7.0 (which was just released) a lot of info on the Internet may be out of date, so you may want to read up on how to use it:

  • dompdf README
  • dompdf 0.7.0 release notes
  • dompdf wiki (pay attention to any versioning information)

最后,dompdf包含一种可以支持您的字符的字体(DejaVu).尝试将以下内容添加到样式表中,以防万一您的自定义字体不起作用:

Lastly, dompdf includes a font (DejaVu) that can support your characters. Try adding the following to your stylesheet so that you have a fallback in case your custom font doesn't work:

* { font-family: BZar_0, DejaVu Sans, sans-serif; }

这篇关于我找不到用于设置"DOMPDF_UNICODE_ENABLED"的dompdf_config.inc.php或dompdf_config.custom.inc.php.真的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆