Embedding Apache fop 2.1 in java servlet

前端 未结 1 1675
礼貌的吻别
礼貌的吻别 2021-01-19 16:29

I have an application that uses Apache FOP to generate PDF files. Everything works great, except Cyrillic letters in the generated PDF. As far as I understand, I am supposed

相关标签:
1条回答
  • 2021-01-19 17:09

    At the moment you are not using your configuration file, so the fonts are not configured and they are not embedded in the PDF output.

    The URI parameter in the FopFactoryBuilder constructor is used to resolve relative URIs, not to load the configuration file.

    As per embedding instructions, your code should have something similar to this:

    import org.apache.avalon.framework.configuration.Configuration;
    import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
    
    ...
    
    DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
    Configuration cfg = cfgBuilder.buildFromFile(new File("conf/conf.xml"));
    FopFactoryBuilder fopFactoryBuilder = new FopFactoryBuilder(new File(".").toURI()).setConfiguration(cfg);
    FopFactory fopFactory = fopFactoryBuilder.build();
    
    0 讨论(0)
提交回复
热议问题