You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by "Gregan, Miroslav" <mi...@siemens.com> on 2008/02/18 14:03:01 UTC

Help for setting in FOP 0.20.5

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

Help for setting in FOP 0.20.5

Posted by "Gregan, Miroslav" <mi...@siemens.com>.
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

RE: Help for setting in FOP 0.20.5

Posted by "Gregan, Miroslav" <mi...@siemens.com>.
Thank you very much, it's exactly what I was looking for :)

Miro

-----Original Message-----
From: Jeremias Maerki [mailto:dev@jeremias-maerki.ch] 
Sent: Tuesday, February 19, 2008 9:10 AM
To: fop-users@xmlgraphics.apache.org
Subject: Re: Help for setting in FOP 0.20.5

Take a closer look at configuration.html and embedding.html in the
build/site directory of the binary distribution of 0.20.5. It explains
how you can use the "fontBaseDir" setting for specifying the base
directory for relative file names. If I remember correctly, the
"baseDir"
value is used if no "fontBaseDir" value is set.

At any rate, you don't have to do anything with the triplets. They seem
to be ok.

On 18.02.2008 14:03:01 Gregan, Miroslav wrote:
> 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




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Help for setting in FOP 0.20.5

Posted by Jeremias Maerki <de...@jeremias-maerki.ch>.
Take a closer look at configuration.html and embedding.html in the
build/site directory of the binary distribution of 0.20.5. It explains
how you can use the "fontBaseDir" setting for specifying the base
directory for relative file names. If I remember correctly, the "baseDir"
value is used if no "fontBaseDir" value is set.

At any rate, you don't have to do anything with the triplets. They seem
to be ok.

On 18.02.2008 14:03:01 Gregan, Miroslav wrote:
> 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




Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org