DOMPDF problem with Cyrillic characters

后端 未结 7 1277
故里飘歌
故里飘歌 2020-12-08 17:48

I am using the DOMPDF library to create an invoice in PDF. This document can be in French, Russian or English, but I am having trouble printing Russian characters.

F

7条回答
  •  粉色の甜心
    2020-12-08 18:21

    if you will use DejaVu font you can see cyrillic characters

    The DejaVu TrueType fonts have been pre-installed to give dompdf decent Unicode character coverage by default. To use the DejaVu fonts reference the font in your stylesheet, e.g. body { font-family: DejaVu Sans; } (for DejaVu Sans).

    DOMPDF include DejaVu font be default

        $html = "".
            "А вот и кириллица".
            "";
    
        $dompdf = new \DOMPDF();
        $dompdf->load_html($html);
        $dompdf->render();
        echo file_put_contents('cyrillic.pdf', $dompdf->output());
    

    You can also set change def for font by default in dompdf_config.inc.php

    def("DOMPDF_DEFAULT_FONT", "DejaVu Sans");
    

提交回复
热议问题