I have uploaded a small example here. It is composed of 3 files.
I would like to use DOMPDF to render a Laravel view on the server side. I realized the font I am using Open Sans is not working so I made a simpler test which shows the same issue.
If you try to call index.php wou will get this PDF in which the Lorem title is not rendered with Open Sans.
composer.json
{
"name": "nowox/test-dompdf",
"require": {
"dompdf/dompdf": "^0.8.3",
"webfontkit/open-sans": "^1.0"
}
}
index.php
<?php
require 'vendor/autoload.php';
use Dompdf\Dompdf;
use Dompdf\Options;
$options = new Options();
$options->set('defaultFont', 'Open Sans');
$options->set('fontDir', 'vendor/webfontkit/open-sans/fonts');
$dompdf = new Dompdf($options);
$dompdf->loadHtml(file_get_contents('template.html'));
$dompdf->setPaper('A4');
$dompdf->render();
$dompdf->stream();
index.html
* {
font-family: 'Open Sans';
}
h1 {
font-family: 'Open Sans';
}
Lorem
Lorem ipsum
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)