2

Hy there, I'm using html2pdf v3 to create a PDF. That works pretty good. But now I wanted to use Google Fonts inside the PDF. So I downloaded Roboto-Regular.ttf and renamed it to roboto.ttf. Then I converted it to .php and .z (Encoding: cp1252): http://www.fpdf.org/makefont/index.php

Then I copied those two files inside the "fonts" folder and included the font:

$html2pdf = new HTML2PDF('P', 'A4', 'de', true, 'UTF-8', array(30,18,30,18));
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->AddFont('roboto', 'normal', 'roboto.php');
$html2pdf->writeHTML($css.$content);
$html2pdf->Output($path.$pdf_name, 'F');

Unfortunately the Roboto Text has some pretty weird widths:

HTML:

<p>This is written with default Font Family</p>
<p style="font-family:roboto">This is written with Roboto</p>

Output:

enter image description here

The same happens when I set Roboto as default font $html2pdf->setDefaultFont('roboto');

Is there any solution for this?

Nico Martin
  • 1,268
  • 1
  • 14
  • 23

1 Answers1

1

I used now a different encoder: fonts.snm-portal.com Now it works.

Nico Martin
  • 1,268
  • 1
  • 14
  • 23