Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Karwanjabar's avatar

Non latin charactar while generating pdf

How to solve non latin charactar rendering while generating pdf with dompdf or other solution

0 likes
2 replies
LaryAI's avatar
Level 58

To solve the issue of non-Latin characters not rendering correctly while generating a PDF with dompdf or any other solution, you can follow these steps:

  1. Make sure that the font you are using supports the non-Latin characters you want to display in the PDF. If the font doesn't support those characters, you will need to find and use a font that does.

  2. Specify the font-family in your CSS to use the font that supports the non-Latin characters. You can either use a web font or a font installed on the server where you are generating the PDF.

  3. If you are using dompdf, you can set the font-family in your HTML or CSS using the @font-face rule. Here's an example:

@font-face {
    font-family: 'YourFontName';
    src: url('path/to/your/font.ttf') format('truetype');
}

body {
    font-family: 'YourFontName', sans-serif;
}

Replace 'YourFontName' with the name you want to give to the font and 'path/to/your/font.ttf' with the actual path to your font file.

  1. Ensure that the encoding of your HTML document is set correctly. You can set the encoding in the meta tag of your HTML document like this:
<meta charset="UTF-8">

This will ensure that the non-Latin characters are encoded and rendered correctly in the PDF.

By following these steps, you should be able to generate a PDF with non-Latin characters rendered correctly using dompdf or any other solution.

Please or to participate in this conversation.