I Can't Find dompdf_config.inc.php or dompdf_config.custom.inc.php for setting “DOMPDF_UNICODE_ENABLED” true

自作多情 提交于 2019-12-05 14:02:50
BrianS

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. 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.

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.

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.

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:


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; }

To set any DOMPDF option you have to define a named constant. All available options can be found here: http://pxd.me/dompdf/www/setup.php

To enable Persian characters you basically have to enable unicode support.

define("DOMPDF_UNICODE_ENABLED", true);

You may want to set DOMPDF_FONT_DIR and DOMPDF_DEFAULT_FONT as well, just to make sure that the font you're using supports unicode characters.

I just added dompdf_config.inc.php and dompdf_config.custom.inc.php files from dompdf 0.6.2 version, besides include dir with autoload.inc.php and functions.inc.php to my dompdf 0.8.* and it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!