Here's some sample code I use for configuring the PDFRenderer for the

import org.apache.avalon.framework.ExceptionUtil;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
import org.apache.avalon.framework.container.ContainerUtil;
import org.apache.avalon.framework.context.DefaultContext;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.avalon.framework.logger.Logger;
import org.apache.fop.apps.Driver;
import org.apache.fop.apps.FOPException;
import org.apache.fop.pdf.PDFEncryptionParams;


    public void convertFO2PDF(File fo, File pdf) throws Exception {
        Logger console = new ConsoleLogger(ConsoleLogger.LEVEL_INFO);

        DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
        Configuration cfg = cfgBuilder.buildFromFile(
            "D:/Java/workspace/FOP Main Sandbox/src/xml/pdf-renderer-cfg.xml");
        //Construct driver
        Driver driver = new Driver();
        //Setup logger

        FOUserAgent ua = new FOUserAgent();
        //ua.setPDFEncryptionParams(new PDFEncryptionParams(null, "owner", false, 
false, true, true));


        //Setup Renderer (output format)        
        ContainerUtil.configure(driver.getRenderer(), cfg.getChild("pdf-renderer"));
        driver.getRenderer().setCreator(DebugFO2PDF.class.getName() + " (dödeldädel)");
        //Setup output
        OutputStream out = new;
        out = new;
        try {

            //Setup input
            InputStream in = new;
            try {
                driver.setInputSource(new InputSource(in));
                //Process FO
            } finally {
        } finally {

We decided at one time to rewrite the CLI using Commons CLI so I'm not
sure if it is worth a lot of effort to fix the current CLI in the
redesign. Also, doing the move to Commons CLI now could mean some
rewriting as soon as the Avalon Container is in place. But that's
probably not so bad. As Keiron said, just yell if you need help. I'm
looking forward to any patch on the redesign!

On 02.04.2003 05:27:26 Keiron Liddle wrote:
> > Thanks Keiron for the feedback!
> > 
> > I found and reviewed the discussion regarding the move to Avalon (ref:  
> > ).
> > 
> > I also appreciate your point that some aspects of configuration have  
> > already been 're-enabled'; as exemplified in  
> > which calls commandLineOptions.getOutputFile() and  
> > commandLineOptions.getRendererOptions().
> > 
> > I want to use the -c option to import a font refed in a userconfig.xml  
> > file as per  
> > 
> > N10261
> > 
> > I can see that CommandLineOptions.parseOptions(...) is caching my  
> > userconfig.xml file in its userConfigFile member. Grepping the source  
> > does not reveal anyone calling the getUserConfigFile() accessor and I'm  
> > unable to find anyone parsing the userConfigFile, so this is what I  
> > mean when I say that I suspect configuration is not completely  
> > "re-enabled."
> To get the configuration we will probably use the DefaultConfigurationBuilder in 
> avalon framework:
> The buildFromFile will return a Configuration object which holds all the 
> configuration data.
> If you then look in org.apache.fop.render.pdf.PDFRenderer in the configure 
> method you will see that it reads the filter and font information.
> I don't think there is any code to hook this up.
> You could do the filename to Configuration object in the Driver. Then it could call 
> configure on the Renderer. I think it will need to get a child Configuration object 
> that matches the mime type for the renderer. Take a look at xml-fop/conf/fop.xconf 
> for a draft of the configuration XML format.
> Good luck. If you need any more help then give us a yell.
> > So, I guess my question now is: Are CommandLineOptions.userConfigFile  
> > font tags being processed? If so, then where? If not, then... yes,  
> > given some pointers, I'm interested in helping to get it working.

Jeremias Maerki

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

Reply via email to