Question
Custom font style is not applied in the generated pdf document
A custom font file is uploaded to our Pega Application as a binary file. File directory of the binary file is webwb and the extension is ttf. In the Rich Text Editor(RTE) I have added this font style and applied this style to the content of the RTE. Now when I am generating the pdf out of the content of RTE, the custom font style is not applied to the generated pdf. I am using HTMLToPDF activity for generating the pdf and passing the parameters like pdfstream, pyPDFFontsDirectory and pyPDFEmbedFont as true. PDF is generated properly but not with the desired custom font style. I have tried passing parameter of pyPDFFontsDirectory as webwb, as \webwb and even my local directory path as well like "C:\\Windows\\Fonts". None of them worked. I have gone through many community posts but could not find the desired solution. I feel there is an issue with passing the directory path. Please help!!
***Edited by Moderator Marissa to update platform capability tags****
For using custom font styles in PDF generation, few important things:
- You need to pass pyPDFFontsDirectory parameter to a folder location on Pega Server. I'd suggest use a folder other than c:/windows/fonts, as Pega automatically creates a file named pd4fonts.properties in the fonts directory and in most cases Pega may not have access to create this file under c:/windows/fonts. Also note, to use forward slash (/) for directory separator not backward slash (\).
- The html stream passed to HTMLToPDF activity should have respective css for each part of the HTML using the custom font. For example, the css may have a class defined with font-family and then that class is used for div or table/tr/td tags in html.
- pyPDFEmbedFont parameter must be passed as true for HTMLToPDF activity to embed the custom fonts inside the rendered PDF. Once a PDF is generated, you can check its properties (fonts tab) to check if the custom font was embedded.
Hope this helps.