H
H
hatman2018-09-15 09:23:41
symfony
hatman, 2018-09-15 09:23:41

How to enable Russian language support in Dompdf?

Hello everyone
I want to convert html page to pdf. The page itself contains only html code without css. I do everything using the Dompdf extension.
Installed with Composer

public function index()
    {
        // Configure Dompdf according to your needs
        $pdfOptions = new Options();
        $pdfOptions->set('defaultFont', 'Arial');
        
        // Instantiate Dompdf with our options
        $dompdf = new Dompdf($pdfOptions);
        
        // Retrieve the HTML generated in our twig file
        $html = $this->renderView('default/mypdf.html.twig', [
            'title' => "Welcome to our PDF Test"
        ]);
        
        // Load HTML to Dompdf
        $dompdf->loadHtml($html);
        
        // (Optional) Setup the paper size and orientation 'portrait' or 'portrait'
        $dompdf->setPaper('A4', 'portrait');

        // Render the HTML as PDF
        $dompdf->render();

        // Output the generated PDF to Browser (force download)
        $dompdf->stream("mypdf.pdf", [
            "Attachment" => true
        ]);
    }

Here is a year that generates pdf, where all Russian characters are displayed as questions. I tried to register the font through the css file, embed the font in html.
Information about the client
The result is similar. How do you set the font to work?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Novoselov, 2018-09-15
@hatman

Problem with cyrillic characters, try https://github.com/dompdf/dompdf/wiki/UnicodeHowTo

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question