0

I have devanagari script in my html file. But it is displayed as ?????? in the .pdf file. how to solve this problem?

This is the html code

<style>
  @font-face {
    src: url("/Shivaji01.ttf");
    font-family: "Shivaji01";
  }
</style>

<p style="text-align:center;font-family:Shivaji01"> फोंडा - गोवा 403401 </p>

and i am getting this error: Undefined index:in \vendor\dompdf\dompdf\lib\Cpdf.php

  • 1
    Welcome to StackOverflow! It's unclear what you are asking. Could you add some details about what you are trying to achieve, more code, and what steps are needed in order to reproduce your issue. You can take a look at https://stackoverflow.com/help/how-to-ask to help you reformulate your question – Matthieu Libeer Aug 05 '19 at 18:29

2 Answers2

2

Are you using the utf8? Which font did you choose? Make sure that the font contains the characters and the document is in the correct encoding.

I hope this helps: dompdf character encoding UTF-8

0

step 1) add your font's ttf(TrueType font),afm(Adobe Font Metrics) and ufm types in your vendor/dompdf/lib/fonts file.

step2) edit your "dompdf_font_family_cache.dist.php" file. add

'yourFontName' =>
        array(
            'bold' => $distFontDir . 'yourFontName',
            'bold_italic' => $distFontDir . 'yourFontName',
            'italic' => $distFontDir . 'yourFontName',
            'normal' => $distFontDir . 'yourFontName',
        ),

step 3) in your css, add

@font-face {
            src: url("/PathToyourFont.ttf");
            font-family: "yourFontName";
 } 

step 4) in your css, you can use your font inside font-family

body {
         margin-right: 1cm;
         margin-left: 1cm;
         font-family: "yourFontNamr",Helvetica,Arial,sans-serif;
      }
Rhugveda Desai
  • 74
  • 2
  • 11