Documentation for custom fonts in flying saucer

I’ve been trying to add custom fonts to a PDF generated with but I can’t get it to work. There is some documentation on how to do this using the classic engine, but for Flying Saucer there is barely any documentation and whatever is there, is contradictory.

In once place it says the following:

Note : Classic engine works using the font-family-name from pd4fonts.properties file. Modern (Flying saucer) engine works using the font-family-name from the .ttf file with the same case.”

This suggests that a pd4fonts.properties file is not longer necessary. But in the documentation for it says:

“fontdirectory: directory that contains additional font files (.ttf) and a pd4fonts.properties to describe them.”

This suggests that you should, in fact, create a pd4fonts.properties file with flying saucer. But then the question becomes: how to create it? Where to find an example? The only thing I can find are Java-tools to install, which makes it really hard. At the same time, it seems it’s just a text file, a simple example would go a long way.

Perhaps I’m overlooking something completely different and flying saucer makes embedding fonts truly easy. But for now I find this reason to switch back to classic, simply because there the method of embedding fonts is documented.

Not sure whom I should be asking, but if anyone could contribute some additional documentation, that would help relative newbies like myself a lot!

Hi @andoradmiraal,

I had to look at this a while ago and the trick is to create a fonts directory and then set the path to it in the application.cfc:

this.pdf.fontDirectory = getDirectoryFromPath(getCurrentTemplatePath()) & "..\fonts\";

I believe that you can also set a fontDirectory attribute on cfdocument itself, but I have not tried that.

Give that a while and see how you get on.

3 Likes