I have copied a TTF font file into the fonts/ subfolder of the velocityreport.reportfolder setting. When I call ```
plugins.VelocityReport.installFonts();
Would anyone know if there is any way of determining what is going wrong? Is there a step I'm missing?
Thanks in advance,
This method is useful for Smart Client only. It pushes the font on the client’s machine to be used in PDF reports.
For all other types of clients Web/NG/Velocity/headless this method does nothing.
For a font (other than system fonts) to be used in a report it has to be installed on the system where the PDF is generated.
For all clients except Smart, this is the server system, so the font has to be installed on the server.
No problem! Glad to hear you’re giving the plugin a try, I’m pretty proud of this project which is more than 10 years old and that I’ve maintained and grown to be a real Swiss tool with many applications making it an essential addition to any Servoy install.
There’s tons you can do with it, more than just its reporting capabilities, like building REST APIs, or even creating entire web apps with Velocity Web Client giving you total freedom on the templating/framework you use client-side.
I have installed the font onto my local machine and it is not being picked up when I render the PDF using plugins.VelocityReport.getPDFReport(). However, it is being picked up if I open the page directly in a browser.
Please try with the latest version of the Velocity plugin (v3.5.91) where I have fixed a few things.
You will have to put the fonts file (in either .ttf/.otf/.ttc format) in a /fonts folder inside your velocity reports folder (the velocity reports folder is the one that is pointed at by the velocityreport.reportFolder property in servoy-admin)
Also make sure you use the correct case for your font in the font-family CSS (the iText lib is embedding the fonts in the PDF based on their internal name which is case sensitive).
I’ve upgraded to the latest version; you mentioned previously that the instructions were for the Web Client and not NG Client? So we still need to copy the font even for NG Client?
I’ve installed the font and tried copying across the Montserrat ttf files to the fonts sub-folder. I put the Montserrat-Regular.ttf, Montserrat-Bold.ttf and Montserrat-Italic.ttf; then I just removed them and put the regular one in as Montserra.ttf. I restarted the app each time. And restarted Servoy too but to no avail.
When we specify the font family in the CSS as above; does it look for the exact name in the fonts folder or as an installed font?
Yes, you need to put the fonts in a/fonts folder, this is what I’ve changed when realizing that iText doesn’t pick system installed fonts apart from a few standard one.
So when the PDF is produced, I force all fonts found in the fonts folder into the iText context, then they are available if they are used in your CSS.
Now I did a simple test, putting the “Montserrat-Regular.ttf” file into the $REPORTS_FOLDER$/fonts/ folder, with this simple HTML template:
And got a resulting PDF with the Montserrat font embedded.
So perhaps, check that you are pointing to the correct velocity reports folder, and that you have your fonts in a folder called “fonts” (case sensitive) at the root of the velocity reports folder, like reports/fonts/Montserrat-regular.ttf and it should work.