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.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjU2ODE0NjQsIm5iZiI6MTcyNTY4MTE2NCwicGF0aCI6Ii80NjUyNDA3NC8zMzYxMjI3MzAtNTg2YmNmMmUtYTkyNy00MTcxLWE0OGQtYjM1Y2M3N2IxNjUyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA5MDclMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwOTA3VDAzNTI0NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU2M2YzZWQyMDc1ZWE3YzFiYzkyNGJhNGQ0ZTNkMzk4MzI0YmMyZDcxZGY5YjQ5YzVmOWMyMzg2N2MzNzI3ZjMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.Thcffg0LJHcJ0uUozIJXbV0cWb9vk_U5Anzctgz4JBQ)
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: