xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gregan, Miroslav" <miroslav.gre...@siemens.com>
Subject Help for setting in FOP 0.20.5
Date Mon, 18 Feb 2008 13:03:01 GMT
Hi all,
 
I know I should upgrade to the latest FOP, and it will be done for our
next tool's release (finally...).
(I have solved already this problem with FOP 0.94)
 
But until that next release... I have a font problem with the old
version.
 
So I'm using FOP 0.20.5 embedded in a java program, I have a
parameterized XSL sheet and an on the fly built XML document (stored in
DOM object).
 
The thing is that I need to print Unicode characters and I want to use a
specific font (DejaVuSans.ttf).
 
Knowing that the tool using FOP has an unknown location, I need to use a
relative path.
 
Can I make something like that: (set XSL parameter + define config
file)?
 
If so, how do I set the config.xml or/and the userconfig.xml and what
path should I put in that config file for the font?
 
 
 
This is the code I'm using, with a commented try to use something else
(starter + commandLineOptions) but I cannot set XSL parameters.
 
    FileOutputStream outputStream = null;
    try {
        outputStream = new FileOutputStream(new
File(reportParameters.getOutputFileName()));
        Driver driver = new Driver();
        driver.setOutputStream(outputStream);
        driver.setRenderer(Driver.RENDER_PDF);
        driver.setLogger(logger);
 
        sheetsMap = loadResources();
        String sUrl = sheetsMap.get(reportParameters.getReportType());
        URL urlpath = new URL(sUrl);
 
        Transformer transformer =
TransformerFactory.newInstance().newTransformer(new StreamSource(new
File(urlpath.getPath())));
        transformer = setTransformationParams(transformer,
reportParameters);
 
        transformer.transform(new StreamSource(new
StringReader(rh.toString())), new
SAXResult(driver.getContentHandler()));
 
        // TransformerFactory transformerFactory =
TransformerFactoryImpl.newInstance();
        // transformerFactory.
        // URL configUrl =
FileLocator.find(ReportsPlugin.getDefault().getBundle(), new
Path(ReportsPlugin.getReportsResourceString
(TRANSFORMATION_FOP_CONFIGFILE_LOCATION)), null); 
        //
        // String[] args = new String[]{"-c",
FileLocator.resolve(configUrl).getFile(), "-fo",
reportParameters.getOutputFileName()+".fo", "-pdf",
reportParameters.getOutputFileName()};
        // CommandLineOptions commandLineOptions = new
CommandLineOptions(args);
        // Starter starter = commandLineOptions.getStarter();
        // starter.run();
 
    } catch (OutOfMemoryError outOfMemoryError) {
        throw new ReportException(ReportException.OUT_OF_MEMORY_ERROR);
    } finally {
        if (outputStream != null) {
            outputStream.close();
        }
    }
 
 
 
 
the config.xml content (metrics file are generated, correctly I suppose,
because I couldn't test it until now):
 
...
        <font metrics-file="font/DejaVuSans.xml"
embed-file="font/DejaVuSans.ttf" kerning="yes">
            <font-triplet name="DejaVuSans" style="normal"
weight="normal" />
        </font>
        <font metrics-file="font/DejaVuSans-Bold.xml"
embed-file="font/DejaVuSans-Bold.ttf" kerning="yes">
            <font-triplet name="DejaVuSans" style="normal" weight="bold"
/> 
        </font>
    </fonts>
 
 
Should I set other triplets style and weight and use a different name
when I need to use the bold font?
Where should be the font directory location if I set this path (see
config.xml content)?
 
 
Thanks for your help.
 
Cheers,
 
Miro

Mime
View raw message