<bdo id='R1XlM'></bdo><ul id='R1XlM'></ul>
<tfoot id='R1XlM'></tfoot>

      <small id='R1XlM'></small><noframes id='R1XlM'>

      <i id='R1XlM'><tr id='R1XlM'><dt id='R1XlM'><q id='R1XlM'><span id='R1XlM'><b id='R1XlM'><form id='R1XlM'><ins id='R1XlM'></ins><ul id='R1XlM'></ul><sub id='R1XlM'></sub></form><legend id='R1XlM'></legend><bdo id='R1XlM'><pre id='R1XlM'><center id='R1XlM'></center></pre></bdo></b><th id='R1XlM'></th></span></q></dt></tr></i><div id='R1XlM'><tfoot id='R1XlM'></tfoot><dl id='R1XlM'><fieldset id='R1XlM'></fieldset></dl></div>
      <legend id='R1XlM'><style id='R1XlM'><dir id='R1XlM'><q id='R1XlM'></q></dir></style></legend>

      1. dompdf 字符编码 UTF-8

        时间:2023-10-03
        • <bdo id='2cQbQ'></bdo><ul id='2cQbQ'></ul>
            <tbody id='2cQbQ'></tbody>
        • <i id='2cQbQ'><tr id='2cQbQ'><dt id='2cQbQ'><q id='2cQbQ'><span id='2cQbQ'><b id='2cQbQ'><form id='2cQbQ'><ins id='2cQbQ'></ins><ul id='2cQbQ'></ul><sub id='2cQbQ'></sub></form><legend id='2cQbQ'></legend><bdo id='2cQbQ'><pre id='2cQbQ'><center id='2cQbQ'></center></pre></bdo></b><th id='2cQbQ'></th></span></q></dt></tr></i><div id='2cQbQ'><tfoot id='2cQbQ'></tfoot><dl id='2cQbQ'><fieldset id='2cQbQ'></fieldset></dl></div>
          <tfoot id='2cQbQ'></tfoot>

          <small id='2cQbQ'></small><noframes id='2cQbQ'>

                <legend id='2cQbQ'><style id='2cQbQ'><dir id='2cQbQ'><q id='2cQbQ'></q></dir></style></legend>
                  本文介绍了dompdf 字符编码 UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试使用正确的字符创建 pdf,但是有?"字符.我创建了一个测试 php 文件,我试图在其中找到最佳解决方案.如果我在浏览器中打开 html,我看起来没问题

                  Im trying to create pdf with correct characters, but there are "?" chars. I created a test php file, where Im trying to fing the best solution. If Im open in the browser the html I looks like ok

                  UTF-8 --> UTF-8 : X Ponuka číslo € černý Češký 
                  

                  但是当我查看pdf时,我看到了这个

                  But when I look into the pdf I see this

                  UTF-8 --> UTF-8 : X Ponuka ?íslo € ?erný ?ešký 
                  

                  这是我的所有代码:

                  <html>
                  <head>
                      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                      <title>č s š Š</title>
                  </head>
                  <body>
                  <?php 
                  
                  require_once("dompdf/dompdf_config.inc.php");
                  $tab = array("UTF-8", "ASCII", "Windows-1250", "ISO-8859-2", "ISO-8859-1", "ISO-8859-6", "CP1256"); 
                  $chain = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <style></style><title>č s š Š</title></head><body>';
                  foreach ($tab as $i) 
                      { 
                          foreach ($tab as $j) 
                          { 
                              $chain .= "<br> $i --> $j : ".iconv($i, $j, 'X Ponuka číslo € černý Češký <br>'); 
                          } 
                      } 
                  $chain .= '<p style="font-family: firefly, verdana, sans-serif;">??????X Ponuka číslo € černý Češký <br></p></body></html>';
                  echo $chain; 
                  echo 'X Ponuka číslo € černý Češký <br>'; 
                  
                  $filename = 'pdf/_1.pdf';
                  $dompdf = new DOMPDF();
                  $dompdf->load_html($chain, 'UTF-8');
                  $dompdf->set_paper('a4', 'portrait'); // change these if you need to
                  $dompdf->render();
                  file_put_contents($filename, $dompdf->output());
                  
                  ?> 
                  </body>
                  </html>
                  

                  我做错了什么?我尝试了很多我发现的选项:(知道吗?

                  What Im doing wrong? I tried many many options which I found :( Any idea?

                  推荐答案

                  您应该阅读Unicode How-to

                  You should read over the Unicode How-to again. The main problem is that you don't specify a font that supports your characters. It looks like you've read the how-to, because you're using the font example from that document. However the example was not meant to apply globally to any document, dompdf doesn't include firefly (a Chinese character font) or Verdana by default.

                  如果您不指定字体,则 dompdf 会退回到仅支持 Windows ANSI 编码的核心字体之一(Helvetica、Times Roman、Courier).因此,请务必使用支持 Unicode 编码并具有您需要显示的字符的字体来设置文本样式.

                  If you do not specify a font then dompdf falls back to one of the core fonts (Helvetica, Times Roman, Courier) which only support Windows ANSI encoding. So always be sure to style your text with a font that supports Unicode encoding and has the characters you need to display.

                  在 dompdf 0.6.0 中,您可以使用包含的 Deja Vu 字体.所以以下应该工作(只是 HTML):

                  With dompdf 0.6.0 you can use the included Deja Vu fonts. So the following should work (just the HTML):

                  <html>
                  <head>
                  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
                  <style>
                    body { font-family: DejaVu Sans, sans-serif; }
                  </style>
                  <title>č s š Š</title>
                  </head>
                  <body>
                    <p>??????X Ponuka číslo € černý Češký <br></p>
                  </body>
                  </html>
                  

                  这篇关于dompdf 字符编码 UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:联系表单电子邮件主题的 UTF-8 编码 下一篇:如何使用 PHP 跳过 XML 文件中的无效字符

                  相关文章

                  最新文章

                    <bdo id='6vSzf'></bdo><ul id='6vSzf'></ul>

                  <small id='6vSzf'></small><noframes id='6vSzf'>

                  <tfoot id='6vSzf'></tfoot>
                  1. <i id='6vSzf'><tr id='6vSzf'><dt id='6vSzf'><q id='6vSzf'><span id='6vSzf'><b id='6vSzf'><form id='6vSzf'><ins id='6vSzf'></ins><ul id='6vSzf'></ul><sub id='6vSzf'></sub></form><legend id='6vSzf'></legend><bdo id='6vSzf'><pre id='6vSzf'><center id='6vSzf'></center></pre></bdo></b><th id='6vSzf'></th></span></q></dt></tr></i><div id='6vSzf'><tfoot id='6vSzf'></tfoot><dl id='6vSzf'><fieldset id='6vSzf'></fieldset></dl></div>

                    1. <legend id='6vSzf'><style id='6vSzf'><dir id='6vSzf'><q id='6vSzf'></q></dir></style></legend>