Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOMPDF not rendering unicode fonts character as it is #838

Closed
logindian opened this issue Jun 27, 2014 · 13 comments
Closed

DOMPDF not rendering unicode fonts character as it is #838

logindian opened this issue Jun 27, 2014 · 13 comments

Comments

@logindian
Copy link

I used http://eclecticgeek.com/dompdf/load_font.php to generate Unicode TAMIL language font(latha by microsoft font) .I have copied the fonts into respective folders.

But I see the fonts are not printing as it is.

My code:

<p style="font-family: tamil-latha, verdana, sans-serif;" >தமிழ்</p>

But what is printed in PDF is :
untitled

Both the values are not Same. There is some box is coming near the font and a dot on last character is missing..
Font Link : http://font.downloadatoz.com/font,6907,latha.html

Note: I have also added newly created font into dompdf_font_family_cache.dist.php

'tamil-latha' => 
  array (
    'normal' => DOMPDF_FONT_DIR . 'latha',
    'bold' => DOMPDF_FONT_DIR . 'latha',
    'italic' => DOMPDF_FONT_DIR . 'latha',
    'bold_italic' => DOMPDF_FONT_DIR . 'latha',
  ),

Kindly suggest me how should i get the Unicode fonts as similar to original fonts.

@bsweeney
Copy link
Member

First, if you're not using v0.6.1 you should go ahead and upgrade. Then use the built-in font loading tools. You can still use the web-based font prep tool, but what's included with dompdf is much better right now. Third, try disabling font subsetting to see if that helps.

I was able to use the font without any missing glyphs with the following HTML:

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <style>
  @font-face {
    font-family: latha;
    font-style: normal;
    font-weight: 400;
    src: url(http://eclecticgeek.com/dompdf/fonts/latha.ttf) format('true-type');
  }
  </style>
</head>
<body>
  <p style="font-family: latha, DejaVu Sans, sans-serif;">தமிழ்</p>
</body>
</html>

@logindian
Copy link
Author

Thanks. I am using v0.6.1 . can i have the download link please ?

@logindian
Copy link
Author

Tried as you suggested in 3rd option but no luck.
Now PDF contains ???? symbols

Here is my complete code used.

require_once($unsecured_param['home_dir']."/APIs/dompdf-0.6.1/dompdf_config.inc.php");

$cart_body='<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
@font-face {
  font-family: latha;
  font-style: normal;
  font-weight: 400;
  src: url(http://eclecticgeek.com/dompdf/fonts/latha.ttf) format(\'true-type\');
}
</style>

</head>
<body>
    <p style="font-family: latha">தமிழ்</p>
</body>
</html>';


        $dompdf = new DOMPDF();
        $dompdf->load_html($cart_body);//body -> html content which needs to be converted as pdf..
        $dompdf->render();
        $output = $dompdf->output();
        $user_bill_pdf = 'User_Bill_tamil.pdf';
        file_put_contents($user_bill_pdf, $output);//to save pdf into a location
        echo "<br>PDF generated..";

@bsweeney
Copy link
Member

bsweeney commented Jul 1, 2014

Sorry. I meant 0.6.1, .2 is in-the-works.

Do you have read/write access to your temp directory? Is DOMPDF_ENABLE_REMOTE true? Those are the only two things I can think that may affect your output (though I don't know that the latter is necessary). Do you get any PHP errors/notices?

@logindian
Copy link
Author

do you mean /tmp folder ? yes i have.
I have also set following in config file,
define("DOMPDF_ENABLE_REMOTE", true);
define("DOMPDF_DEFAULT_PAPER_SIZE", "a4");
define("DOMPDF_UNICODE_ENABLED", true);

@logindian
Copy link
Author

Could you please simulate this in your directory and give the working sample code ?

@bsweeney
Copy link
Member

bsweeney commented Jul 1, 2014

I had no trouble using your HTML.
http://eclecticgeek.com/dompdf/debug.php?identifier=05106307de016883506829e239aac75c

I don't really see anything wrong with the code so the issue might be somewhere else. Are there any red flags on the setup page (browse to dompdf-0.6.1/www/setup.php)?

@moeseth
Copy link

moeseth commented Aug 22, 2017

@bsweeney
Copy link
Member

bsweeney commented Aug 27, 2017

@moeseth you should start a new discussion on the support forum to work through any problems you're having. Unless you can definitively identify a problem with the solution for a closed issue that is.

That being said, the format specifier in your @font-face declaration should be "truetype" and not "ttf" (a mistake I often make myself).

@ikhan009
Copy link

@moeseth you should start a new discussion on the support forum to work through any problems you're having. Unless you can definitively identify a problem with the solution for a closed issue that is.

That being said, the format specifier in your @font-face declaration should be "truetype" and not "ttf" (a mistake I often make myself).

how to show the Urdu alphabet in my PDF file and how to add the Urdu alphabet Unicode .
in my page urdu font not show

@palistha01
Copy link

palistha01 commented Apr 25, 2019

I have a problem with the character encoding UTF-8.I want to generate pdf which supports Nepali language. I want to fetch data from database which is in Nepali language and display in pdf .

test.php

<?php
$html = '
  <html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <style>
    @font-face {
      font-family: latha;
      font-style: normal;
      font-weight: 400;
      src: url("D:\OrangeHRM\3.3.1\htdocs\test\fonts\CODE2000.TTF") format("true-type");
    }
    </style>
  </head>
  <body>
    Word Details<br/>
    <div style="float:left;width:96%">
    <table border="0" width="100%">
      <tr>
        <th>English Word : </th>
        <td><input type="text" name="enhlish" value="'."भिम कुमारी भट्ट".'"/></td>
      </tr>
      <tr>
        <td colspan="2"><hr/></td>
      </tr>
      <tr>
        <th>Tamli Word : </th>
        <td><input type="text" name="tamli" value="'."sdf".'" style="font-family: latha, sans-serif;" /></td>
      </tr>
    </table>
  </body>
  </html>
';
$filename = "test.php";
require_once 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->loadHtml($html,'UTF-8');
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream($filename);

@bsweeney
Copy link
Member

@palistha01 you should start a new issue rather than comment on a closed one. Also, please indicate which version of Dompdf you are using.

@manojdmali
Copy link

i am searching same solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants