I\'m trying to convert .fo
files to PDF/a with Apache FOP 2.1
with the exemple code given in the documentation. I managed to convert the hell
I was able to create a PDF/A output using the same example files after a few changes:
in the input FO file, I explicitly added font-family="Helvetica"
(or your favourite font family) in a position where it effected all the text
Without this, even if FOP defaults to using Helvetica when no font-family
is set, it apparently is not able to find a configuration for it.
in the configuration file, I mapped the Helvetica font family to an existing font, for example Arial
in the Java code, I configured FOP to use my configuration file, and the user agent to enable accessibility
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.fop.apps.FopFactoryBuilder;
...
DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(new File("/Users/lfurini/fop.xconf"));
FopFactoryBuilder fopFactoryBuilder = new FopFactoryBuilder(new File(".").toURI()).setConfiguration(cfg);
FopFactory fopFactory = fopFactoryBuilder.build();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired
foUserAgent.setAccessibility(true);
foUserAgent.getRendererOptions().put("pdf-a-mode", "PDF/A-1b");
...