I am using dompdf
to generate PDFs from inputs.
The code I use:
require_once (STYLESHEETPATH.'/dompdf/include/autoload.inc.php');
set_include_path(STYLESHEETPATH.'/dompdf');
require_once STYLESHEETPATH.'/dompdf/dompdf_config.inc.php';
$dompdf = new DOMPDF();
$html = '
<html>
<body>
<h1>Hello <i>'. $fullname.'</i> </h1>
<p> your father is <b>'.$fathername.'</b>
</body>
</html>';
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("tck.pdf"); ?>
This works very fine and generates a pdf called tck.pdf
Now I want to style the fonts in the pdf so I've tried
require_once (STYLESHEETPATH.'/dompdf/include/autoload.inc.php');
set_include_path(STYLESHEETPATH.'/dompdf');
require_once STYLESHEETPATH.'/dompdf/dompdf_config.inc.php';
$dompdf = new DOMPDF();
$html = '
<html>
<head>
<style>
@font-face {
font-family: "Open Sans";
font-style: normal;
font-weight: 400;
src: url(http://themes.googleusercontent.com/static/fonts/opensans/v8/cJZKeOuBrn4kERxqtaUH3aCWcynf_cDxXwCLxiixG1c.ttf) format("truetype");
}
</style>
</head>
<body>
<h1>Hello <i>'. $fullname.'</i> </h1>
<p> your father is <b>'.$fathername.'</b>
<br/>
<span style="font-family:webfontregular;">bar code will be here</span>
<div style="font-family:"Open Sans";">Open Sans</div>
</body>
</html>';
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("tck.pdf"); ?>
But it does not work and giving an error as follow :
Fatal error: Class 'Font' not found in /home4/q0i4l0g2/public_html/tck/wp-content/themes/kallyas-child/dompdf/include/font_metrics.cls.php on line 356
I've noticed that whenever I use "@font-face" I am getting this error. Why is that? How can I make it work?
As per the accepted answer in this question Dompdf and set different font-family this should work I think but it does not.