You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
for a clients website, we would like to be be able to style the generated pdf's with a custom font. For our pdf settings (in wishlist.php), we have the following settings:
// PDF
'pdfFilenameFormat' => 'karakters-{id}',
'pdfPath' => '_pdf/template',
'pdfAllowRemoteImages' => true,
'pdfPaperSize' => 'A4',
'pdfPaperOrientation' => 'portrait',
in our template twig file we have for example this code: @font-face {
font-family: 'Mona Sans Wide';
font-style: italic;
font-weight: 800;
src: url({{ "#{currentSite.baseUrl}assets/dist/fonts/Mona-Sans/Mona-Sans-ExtraBoldWideItalic.ttf" }}) format('truetype');
}
I wouldn't recommend using self-hosted fonts for PDFs, and I believe there's performance hits with DomPDF in doing so. You should also use inline CSS in the PDF's Twig template, not a separate CSS file.
You may also need the isRemoteEnabled => true config setting as well. You might want to Google around for DomPDF and using custom fonts.
Question
Hello,
for a clients website, we would like to be be able to style the generated pdf's with a custom font. For our pdf settings (in wishlist.php), we have the following settings:
// PDF
'pdfFilenameFormat' => 'karakters-{id}',
'pdfPath' => '_pdf/template',
'pdfAllowRemoteImages' => true,
'pdfPaperSize' => 'A4',
'pdfPaperOrientation' => 'portrait',
in our template twig file we have for example this code: @font-face {
font-family: 'Mona Sans Wide';
font-style: italic;
font-weight: 800;
src: url({{ "#{currentSite.baseUrl}assets/dist/fonts/Mona-Sans/Mona-Sans-ExtraBoldWideItalic.ttf" }}) format('truetype');
}
and we use a css file like this:
<style>{{ source('_pdf/assets/css/layout.css') }}</style>screenshot of our folder structure:
![image](https://private-user-images.githubusercontent.com/46524074/336122730-586bcf2e-a927-4171-a48d-b35cc77b1652.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNTExNjgsIm5iZiI6MTczOTA1MDg2OCwicGF0aCI6Ii80NjUyNDA3NC8zMzYxMjI3MzAtNTg2YmNmMmUtYTkyNy00MTcxLWE0OGQtYjM1Y2M3N2IxNjUyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDglMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA4VDIxNDEwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA1MTlhM2M4MWNhZWU2NTRhZTY5Nzk2ZjI4ZmUxN2IyMzZlYjQ5OWM3NzgwZmFjNDgwNTE3OTliMGNlZTFiOTAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.U24hY0ZId-raD2f2pkQWeC_Gb8E-8ynLLF7MBwW_DMI)
Unfortunately the fonts get ignored. Is there any way to get to use those ttf files?
Additional context
No response
The text was updated successfully, but these errors were encountered: