Alexander Roussakov
Alexander Roussakov

Reputation: 27

How to use hebrew in HTML2PDF lib php?

There are somebody who succeed to generate "HTML with hebrew text to pdf" with this library? I got ???? instead of hebrew fonts Didn't found any solution in web

Is there any solution for this issue?

Upvotes: 0

Views: 707

Answers (1)

talsibony
talsibony

Reputation: 8766

Its long time since this question was asked I had to answer this because I had the same issue, and assume it will help others. Usually when you see ? or squares instead of font chars it means the font is not includes the language so you have to load another font which includes the lang, Hebrew font for the HTML2PDF lib php will be

    require_once('html2pdf/html2pdf.class.php');
    try {
      $html2pdf = new HTML2PDF('P', 'A4', 'en', TRUE, 'UTF-8');
      $html2pdf->pdf->SetDisplayMode('real');
      $html2pdf->setDefaultFont('dejavusans'); // dejavusans font supports hebrew
      $html2pdf->Output('order.pdf');
    } catch (HTML2PDF_exception $e) {
      writeLog('ERROR creating pdf...' . PHP_EOL . $e);
      exit();
    }

Upvotes: 1

Related Questions