xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brandon Youkstetter <brand...@part.net>
Subject Manually Configuring a PDFRenderer
Date Wed, 06 Jul 2011 03:17:54 GMT
I put together a service that uses FOP to render PDF using FOP 1.0 on
java 6. All worked perfectly when running in eclipse on my development
environment. However, my requirements are for this service to run in a
webMethods (8.2) IDE workflow (also runs on Java 6).

I setup the java service in webMethods placing the required libraries
into directory that is loaded by the webMethods classloaders, but
immediately ran into the following exception:

java.lang.UnsupportedOperationException: Don't know how to handle
"application/pdf" as an output format. Neither an FOEventHandler, nor a
Renderer could be found for this output format.

My guess is this problem stems from a failure to read
the /META-INF/services/ properties files due to the way the webMethods
classloaders are loading things up (please let me know if this
assumption seems faulty). 

After searching through the mailing lists, I found a thread that seemed
to discuss a similar issue. The submitter was having difficulty in lotus
notes. This thread described a solution for manually configuring the
PDFRenderer which I followed.

Specifically, I configured my fop factory with all the element mappings
found in /META-INF/services/org.apache.fop.fo.ElementMapping like so:

    fopFactory = FopFactory.newInstance();
    fopFactory.addElementMapping(new FOElementMapping());
    fopFactory.addElementMapping(new SVGElementMapping());
    fopFactory.addElementMapping(new BatikExtensionElementMapping());
    fopFactory.addElementMapping(new ExtensionElementMapping());
    fopFactory.addElementMapping(new InternalElementMapping());
    fopFactory.addElementMapping(new OldExtensionElementMapping());
    fopFactory.addElementMapping(new XMPElementMapping());
    fopFactory.addElementMapping(new RDFElementMapping());
    fopFactory.addElementMapping(new PSExtensionElementMapping());
    fopFactory.addElementMapping(new AFPElementMapping());
    fopFactory.addElementMapping(new PCLElementMapping());

Then I created a user agent to overwrite the Renderer like this:

    FOUserAgent ua = factory.newFOUserAgent();
    PDFRenderer pdfRenderer = new PDFRenderer();
    pdfRenderer.setUserAgent(ua);
    ua.setRendererOverride(pdfRenderer);
    fop = factory.newFop(MimeConstants.MIME_PDF, ua, output);

This setup got me past the UnsupportedOperationException in the
RendererFactory and produced a result. However, the output is a 15 byte,
seemingly invalid result which Ive attached.  

What am I missing? Why am I getting this strange result? Any help would
be greatly appreciated. 

-- 
Brandon Y.

Mime
View raw message