On Mon, Jul 05, 2004 at 03:55:57PM +0200, tango ray wrote:
> But if I succeed in integrating it in the new fop version, I suppose that I
> will have to use :
>
>
> File userConfigFile = new File("C:\\fop\\userconfig.xml"); // -----> here
> is it possible to specify a usercong.xml and metrics file that are include in
> my fop.jar??
> Options options = new Options();
> options.loadUserconfiguration(userConfigFile);
>
>
> Driver driver = new Driver(foFile, out);
>
> driver.setLogger(log);
> driver.setRenderer(Driver.RENDER_PDF);
>
> driver.run();
You still have to configure the renderer. I have prepared this code:
class apps.Fop:
private static Configuration getRendererConfig
(Configuration userConfig, String mimeType) {
if (userConfig == null || mimeType == null) {
return null;
}
Configuration rendererConfig = null;
Configuration[] cfgs
= userConfig.getChild("renderers").getChildren("renderer");
for (int i = 0; i < cfgs.length; ++i) {
Configuration cfg = cfgs[i];
try {
if (cfg.getAttribute("mime").equals(mimeType)) {
rendererConfig = cfg;
break;
}
} catch (ConfigurationException e) {
// silently pass over configurations without mime type
}
}
return rendererConfig;
}
public static void main(String[] args) {
...
AbstractRenderer renderer = driver.getRenderer();
if (renderer != null) {
renderer.setOptions(options.getRendererOptions());
String mimeType = null;
// User configuration options only work for the PDF
renderer.
// How are other renderers identified in the configuration
file?
if (renderer instanceof PDFRenderer) {
mimeType = ((PDFRenderer) renderer).MIME_TYPE;
}
Configuration rendererConfig
= getRendererConfig(options.getUserConfig(),
mimeType);
if (rendererConfig != null) {
renderer.configure(rendererConfig);
}
}
Glen has changed the setup here recently, and I have not yet adapted
this code. The important thing, however, is
renderer.configure(rendererConfig). The config is constructed as in
xml-fop/conf/fop.xconf, element renderers. rendererConfig is the child
element renderer for the PDF renderer, which contains filterList and
fonts. In your app this is the only element you require.
Regards, Simon
--
Simon Pepping
home page: http://www.leverkruid.nl
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]