Petar,

Here's some example code to do this. You guessed right about the Avalon
Configuration object. As implementation of that interface you can actually
use Avalon's own DefaultConfiguration which is in avalon-framework.jar.
For further information about working with Configuration objects please
look at the Javadocs for Avalon Framework (package
org.apache.avalon.framework.configuration). Below you find the code to
build Configuration objects from a file.

AbstractFOPTranscoder transcoder = new org.apache.fop.svg.PDFTranscoder();
ContainerUtil.enableLogging(transcoder, new 
ConsoleLogger(ConsoleLogger.LEVEL_DEBUG));
DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(new File("pdf-renderer-cfg.xml"));
ContainerUtil.configure(transcoder, cfg);
//Optional:
transcoder.addTranscodingHint(PDFTranscoder.KEY_STROKE_TEXT, Boolean.TRUE);
[......]

The XML with the configuration should have the following layout:

<?xml version="1.0" encoding="UTF-8"?>
<cfg>
  <filterList> <!--filterList is optional, I think-->
    <value>flate</value>
    <value>ascii-85</value>
  </filterList>
  <font metrics-url="file:ARIAL.TTF.xml" kerning="no" 
embed-url="file:ARIAL.ttf">
    <font-triplet name="Arial" style="normal" weight="normal"/>
  </font>
  <font metrics-url="file:ARIALBD.TTF.xml" kerning="no" 
embed-url="file:ARIALBD.ttf">
    <font-triplet name="Arial" style="normal" weight="bold"/>
  </font>
  <font metrics-url="file:BauerBodoni-Roman.xml" kerning="no" 
embed-url="file:BauerBodoni-Roman.pfb">
    <font-triplet name="BauerBodoni" style="normal" weight="normal"/>
  </font>
</cfg>

Note that you can also embed the above "cfg" element within a bigger XML
file. You can access child Configuration objects from their parent
Configuration objects by calling getChild(String name), for example. See
Avalon Javadocs.

Note also, that the above code applies to the main CVS branch
(HEAD/trunk/redesign) only.

No guaratee, that the above will work right now. It used to, three months
ago. I'll try to update the example in the next few days.

I hope this helps.

On 21.10.2003 05:12:27 OBRADOVIC,PETAR (HP-Vancouver,ex1) wrote:
> My apology for posting the question below to the dev list.  It was meant to
> go to the user list.
> 
> Petar
> 
> -----Original Message-----
> From: OBRADOVIC,PETAR (HP-Vancouver,ex1) [mailto:[EMAIL PROTECTED] 
> Sent: Monday, October 20, 2003 7:29 PM
> To: FOP ([email protected])
> Subject: PDFTranscoder configuration and CVS branches
> 
> 
> I have downloaded the FOP's main branch and I have built it successfully.
> After playing with the PDFTranscoder  (only, no FOP) for several days I
> wanted to take the next step and try to add some custom fonts.  I traced
> through the code and I think I need to provide a configuration class which
> implements Avalon's Configuration interface and at the same time can parse
> FOP's configuration file (for font metrics).
> 
> I was not able to find such class.  I noticed that there is
> src/java/org/apache/fop/configuration package in Alt-Design and
> src/org/apache/fop/configuration in fop-0_20_5 but I could not find anything
> in the main trunk.  Previously mentioned classes do not implement
> Configuration interface but could at least be a start for one.  In addition,
> I was not able to find any configuration related classes in the trunk.
> 
> How can I configure the latest PDFTranscoder code?  Am I looking in wrong
> places?



Jeremias Maerki


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to