Loading fonts on CakePHP 4 from Google Fonts
rzorzal opened this issue · 1 comments
rzorzal commented
I'm trying to load custom fonts into my PDF using DOMPDF as my engine but every code tried failed.
Some trys:
- Added
<link href="https://fonts.googleapis.com/css2?family=Kite+One&display=swap" rel="stylesheet">
on HTML - Added
<style> @import url('https://fonts.googleapis.com/css2?family=Kite+One&display=swap'); </style>
- Added as base64
- Added as local file
All that doesn't work for me.
My consiguration is:
Configure::write('CakePdf', [
'engine' => [
'className' => 'CakePdf.DomPdf',
'options' => [
'isHtml5ParserEnabled' => true,
'isRemoteEnabled' => true
]
],
'margin' => [
'bottom' => 0,
'left' => 0,
'right' => 0,
'top' => 0
],
'orientation' => 'portrait',
'download' => false
]);
On Controller:
$this->viewBuilder()->enableAutoLayout(false);
$this->viewBuilder()->setClassName('CakePdf.Pdf');
$this->viewBuilder()->setOption(
'pdfConfig',
[
'orientation' => 'portrait',
'download' => true,
'filename' => 'Report_' . $slug . '_' . $layout . '.pdf' //// This can be omitted if you want file name based on URL.
]
);
What am I doing wrong ?
ADmad commented
Using remote fonts is something I wouldn't do even if it worked. You will have to figure out yourself if it's supported by DomPdf.