Reputation: 131
I am trying to specify a font for my xhtml2pdf
file. By i get this error wrong attributes for <pdf:font>
I am not sure the correct way to specify the attributes for the font?
I have tried searching for a solution to this, but can't find anything.
<!DOCTYPE html>
<html>
<style>
@import url('https://fonts.googleapis.com/css2?family=Itim&display=swap');
</style>
<style>
@media print {
.pagebreak { page-break-before: always; } /* page-break-after works, as well */
}
@page {
size: a4;
margin: 1cm;
@frame footer {
-pdf-frame-content: footerContent;
bottom: 0cm;
margin-left: 9cm;
margin-right: 9cm;
height: 1cm;
}
@font-face {
font-family: 'Itim', cursive;
src: url('https://fonts.googleapis.com/css2?family=Itim&display=swap');
}
</style>
<body>
<p style="font-size:1.3rem;font-family: Itim,sans-serif;">We have generated your PDF!</p>
</body>
Upvotes: 2
Views: 1445
Reputation: 959
According to the documentation on custom fonts xhtml2pdf
only accepts TrueType font or a Postscript font.
You are trying to use OTF
.
Try converting your font to TTF
or Postscript
.
Upvotes: 3
Reputation: 1944
I have tried your example as-is using wkhtmltopdf + pdfkit and got the generated PDF with the following content and font:
Is it the result that you looking for? If yes and you're not really stuck to xhtml2pdf - I can suggest using pdfkit + wkhtmltopdf.
Upvotes: 0