【问题标题】:Upper and lower case Č won't show up properly in dompdf大写和小写 Č 不会在 dompdf 中正确显示
【发布时间】:2012-09-12 09:38:28
【问题描述】:

我已经为此苦苦挣扎了一段时间。

所以我有一个名为 index.php 的简单文件,以 UTF-8 编码。这个文件的内容是:

require_once("dompdf/dompdf_config.inc.php");

$html =
  '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><style> body { font-family: verdana; } </style></head><body>'.
  '<p>Put your html here, or generate it with your favourite '.
  'templating system.</p><p>Č Š Ž č š ž €</p>'.
  '</body></html>';

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf");

基本上,我试图在 PDF 中正确显示字母 Č Š Ž。 Š 和 Ž 工作正常,但我似乎无法让 Č 正确显示,而是我明白了?在我的 PDF 文件中。有什么想法吗?

【问题讨论】:

  • 尝试不同的字体,可以在dompdf中指定字体
  • 我尝试了所有可用的字体,我也 100% 确定 Verdana 支持Č。
  • @Erik 看到 Fabien 的回复。 Verdana 确实支持该字符,但如果该字体未加载到 dompdf 中,它将无法使用它。如果没有支持字体,您将获得您记下的结果。

标签: php unicode utf-8 character-encoding dompdf


【解决方案1】:

guide to enable Unicode in DOMPDF 可以帮助您。如果您使用的是最新版本(0.6beta 或trunk),在底部的网络浏览器dompdf/www/fonts.php 中还有一个新的字体安装程序。另外,请务必查看dompdf/www/setup.php

【讨论】:

  • 此外,在 0.6.0 beta 3 中,您可以跳过加载字体并尝试使用其中一种 DejaVu 字体(例如尝试 DejaVu Sans)。
猜你喜欢
  • 1970-01-01
  • 2014-12-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多