Skip to content
Advertisement

Apache FOP embedded remote fonts

I’m using Apache FOP v2.1 embedded in a Java program. I’m trying to retrieve a remote font using a configuration file similar to the following:

JavaScript

However, when I run the application to generate a PDF file from XML and XSL files it gives me an error:

JavaScript

By checking the source code of FOP I discovered that FOP is trying to add the font to a cache. However, because the font URI is an HTTP URL, when it tries to pass the URL to a java File object, it gives me the error “URI scheme is not file”.

Is there any step I’m missing to load a remote font?

Advertisement

Answer

The problem was the FontCache. It uses File Java class to read the content, and since the configuration file contains URL of http(s) protocol, it throws the mentioned exception. To solve the issue, you need to disable the font cache like this:

JavaScript

By disabling the font cache your remote fonts should be loaded fine without aditional configuration.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement