Support Article
Custom fonts are not picked in the generated PDF
SA-62497
Summary
When generating a PDF with custom fonts (for example, OTF and TTF) from an HTML rule, the custom fonts are not picked in the generated PDF. However, in the Rule preview, the custom fonts are fetched correctly.
Error Messages
Not Applicable
Steps to Reproduce
- Upload any font with TTF or OTF extension as a binary file in Pega using the webwb directory.
- Create an HTML rule.
- Refer the uploaded font using the fontface tag.
- Display text using Div or Font tags.
<html>
<head>
<style>
@font-face {
font-family: GalanoGrotesqueRegular;
src: url('GalanoGrotesqueRegular.otf?');
}
p {color:blue;font-family: GalanoGrotesqueRegular}
</style>
</head>
<body>
<p>GalanoGrotesqueRegular - Some text</p>
</body>
</html>
- Pass the generated HTML rule as a parameter along with the fonts directory to invoke the @baseclass HTMLTOPDF activity.
- Invoke the Call Code-Pega-PDF.View activity to view the generated PDF
Root Cause
Pega levarages PD4ML library for PDF generation. This is not supported by this library.
TTF fonts are supported.
Resolution
Perform the following local-change:
Follow the below pattern while providing a font-family name.
Provide the exact font -family name instead of the font file name. <html>
<head>
<style>
p {color:red;font-family: "Lucida Calligraphy Italic"}
</style>
</head>
<body>
<p>Hello Lucida\ Calligraphy\ Italic</p>
</body>
</html>
Published October 2, 2018 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.