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****
I just fixed the issue. For all who are struggling with the same requirement or issue please follow the steps below:
1. First check the Font Embeddability of the custom font that you want to use is set to Editable or Installable. This you can ensure from the properties of the custom font file by right clicking on it and go to details tab.
2. Place all the font files along with the custom font files which you require to a directory in the server. Make sure that the directory folder is accessible. You can check if the directory path is correct and you are able to access all the files in the path folder by writing a Java code (I wrote a function for this to check). webwb as part of App directory won't work because of the limitation as discussed in this post.
3. Restart the server after placing the font files in the server.
4. Make sure you have the font family of the custom font applied to each element be it div or span. Example: <span style="font-family:century gothic;">Dear Sir</span>
5. Pass the Relative Server path or the Absolute path where the font files are placed in the server as a parameter pyPDFFontsDirectory to HTMLToPDF activity. Make sure that you are using the correct server path which you had verified earlier. In my case I used like /data/..../..../..../Fonts. Replace .... with proper folder names of yours.
6. Pass pyPDFEmbedFont parameter as true to HTMLToPDF activity. This will embed the fonts in the PDF document and you will be able to verify that from the Properties Fonts tab of the adobe acrobat.
Thanks everyone for the help!!
Keep up to date on this post and subscribe to comments
- Custom fonts are not coming in generated PDF with pega provided procedure
- How to apply background style On focus to all fields by creating Custom Style in Skin
- How to apply CSS styling to an auto-generated table in an email?
- How to Create non-Auto generated sections for Applying CSS Styles
- how to apply styles for PDF