Can you start with the embedding.ExampleFO2PDF.java example (in
examples/embedding/java), change the mime type to MIME_PNG (and rename
all the PDFs to PNGs) and confirm that the new example does generate a
PNG file? I just tested that with trunk and it worked.
On 12/27/12 3:02 PM, Milo van der Zee wrote:
Dear FOP users,
I'm using FOP for a couple of years now and thought it was time to
upgrade to version 1.1. Problem is that the rendering to PNG stopped
functioning. It all still works with version 0.95.
PDF generation is still fine. The difference between PNG and PDF
generation is the mime type of fop generated with the factory.
Strange thing is that the call to '*userAgent.getRendererOverride()*'
returns 'null' in version 1.1 and returned the expected PNGRenderer in
version 0.95. Is this a bug or is something changed between versions
in relation to PNG rendering?
From the debug info I see that the renderer does create a page. It
seems like the link between the rendererImpl and the mime-type is not
found. But where can I force that?
See code fragments below.
Thank you very much for any help.,
Milo van der Zee
some relevant code:
---------------------------------------
FopFactory fopFactory = FopFactory.newInstance();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
foUserAgent.setTargetResolution(document.getPreviewDPI());
ByteArrayOutputStream out = new ByteArrayOutputStream();
Fop fop = fopFactory.newFop(*MimeConstants.MIME_PNG*, foUserAgent, out);
TransformerFactory factory = TransformerFactory.newInstance();
Source xslfo = DocumentGenerator.generateXslFo(document);
Transformer transformer = factory.newTransformer(xslfo);
SAXBuilder saxBuilder = new SAXBuilder();
saxBuilder.setErrorHandler(new SaxParserErrorListener());
org.jdom.Document dataDocument = saxBuilder.build(new
StringReader(dataString));
DOMSource src = new DOMSource((new DOMOutputter()).output(dataDocument));
Result res = new SAXResult(fop.getDefaultHandler());
transformer.transform(src, res);
FOUserAgent userAgent = fop.getUserAgent();
*PNGRenderer renderer = (PNGRenderer)userAgent.getRendererOverride();*
---------------------------------------
---------------------------------------
I added this to my pom.xml:
---------------------------------------
<dependency>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>fop</artifactId>
<version>${fop-version}</version>
<exclusions>
<!-- FOP has wrong dependancies on the avalon framework -->
<exclusion>
<groupId>org.apache.avalon.framework</groupId>
<artifactId>avalon-framework-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.avalon.framework</groupId>
<artifactId>avalon-framework-impl</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- these two are to correct issues in fop dependency -->
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-api</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>avalon-framework</groupId>
<artifactId>avalon-framework-impl</artifactId>
<version>4.2.0</version>
</dependency>
---------------------------------------
---------------------------------------
Some debug info:
---------------------------------------
DEBUG org.apache.fop.util.ContentHandlerFactoryRegistry - Dynamically
adding ContentHandlerFactory:
org.apache.fop.render.afp.extensions.AFPExtensionHandlerFactory
DEBUG org.apache.fop.util.ContentHandlerFactoryRegistry - Dynamically
adding ContentHandlerFactory:
org.apache.fop.render.ps.extensions.PSExtensionHandlerFactory
DEBUG org.apache.fop.util.ContentHandlerFactoryRegistry - Dynamically
adding ContentHandlerFactory:
org.apache.fop.fo.extensions.xmp.XMPContentHandlerFactory
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for Renderer: org.apache.fop.render.txt.TXTRendererMaker
DEBUG org.apache.fop.render.RendererFactory - *Dynamically adding
maker for Renderer: org.apache.fop.render.bitmap.PNGRendererMaker*
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for Renderer: org.apache.fop.render.bitmap.TIFFRendererMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for Renderer: org.apache.fop.render.xml.XMLRendererMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for Renderer: org.apache.fop.render.awt.AWTRendererMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for Renderer: org.apache.fop.render.print.PrintRendererMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for FOEventHandler: org.apache.fop.render.rtf.RTFFOEventHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for IFDocumentHandler: org.apache.fop.render.pdf.PDFDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for IFDocumentHandler: org.apache.fop.render.pcl.PCLDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for IFDocumentHandler:
org.apache.fop.render.bitmap.TIFFDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for IFDocumentHandler:
org.apache.fop.render.bitmap.PNGDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for IFDocumentHandler: org.apache.fop.render.ps.PSDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for IFDocumentHandler: org.apache.fop.render.afp.AFPDocumentHandlerMaker
DEBUG org.apache.fop.render.RendererFactory - Dynamically adding maker
for IFDocumentHandler:
org.apache.fop.render.intermediate.IFSerializerMaker
DEBUG org.apache.fop.render.XMLHandlerRegistry - Dynamically adding
XMLHandler: org.apache.fop.render.pdf.PDFSVGHandler
DEBUG org.apache.fop.render.XMLHandlerRegistry - Dynamically adding
XMLHandler: org.apache.fop.render.ps.PSSVGHandler
DEBUG org.apache.fop.render.XMLHandlerRegistry - Dynamically adding
XMLHandler: org.apache.fop.render.java2d.Java2DSVGHandler
DEBUG org.apache.fop.render.XMLHandlerRegistry - Dynamically adding
XMLHandler: org.apache.fop.render.pcl.PCLSVGHandler
DEBUG org.apache.fop.render.XMLHandlerRegistry - Dynamically adding
XMLHandler: org.apache.fop.render.afp.AFPSVGHandler
DEBUG org.apache.fop.render.ImageHandlerRegistry - Dynamically adding
ImageHandler: org.apache.fop.render.pdf.PDFImageHandlerGraphics2D
DEBUG org.apache.fop.render.ImageHandlerRegistry - Dynamically adding
ImageHandler: org.apache.fop.render.pdf.PDFImageHandlerRenderedImage
...
DEBUG org.apache.fop.render.ImageHandlerRegistry - Dynamically adding
ImageHandler: org.apache.fop.render.afp.AFPImageHandlerSVG
DEBUG org.apache.fop.render.AbstractConfigurator - userconfig is null
DEBUG org.apache.fop.render.AbstractConfigurator - userconfig is null
DEBUG org.apache.fop.fonts.FontInfo - Registering: any,normal,400 under F5
...
DEBUG org.apache.fop.fonts.FontInfo - Registering: Webdings,normal,400
under F170
DEBUG org.apache.fop.render.intermediate.IFRenderer - *Rendering areas
via IF document handler*
(org.apache.fop.render.intermediate.EventProducingFilter)...
DEBUG org.apache.fop.fo.FOTreeBuilder - Building formatting object tree
DEBUG org.apache.fop.image.loader.batik.PreloaderSVG - Error while
trying to load stream as an SVG file: Invalid byte 1 of 1-byte UTF-8
sequence.
DEBUG org.apache.fop.image.loader.batik.PreloaderSVG - Error while
trying to load stream as an SVG file: Invalid byte 1 of 1-byte UTF-8
sequence.
DEBUG org.apache.fop.area.AreaTreeHandler - Current heap size: 171055KB
DEBUG org.apache.fop.complexscripts.bidi.BidiResolver - BD: RESOLVE:
org.apache.fop.fo.pagination.PageSequence@bc454f
<mailto:org.apache.fop.fo.pagination.PageSequence@bc454f>[@id=]
...
DEBUG org.apache.fop.layoutmgr.PageSequenceLayoutManager - Starting layout
...
DEBUG org.apache.fop.area.IDTracker - signalIDProcessed()
DEBUG org.apache.fop.render.bitmap.AbstractBitmapDocumentHandler -
Don't know how to handle extension object. Ignoring:
org.apache.xmlgraphics.xmp.Metadata@4ada6e
<mailto:org.apache.xmlgraphics.xmp.Metadata@4ada6e>
(org.apache.xmlgraphics.xmp.Metadata)
INFO org.apache.fop.apps.FOUserAgent - Rendered page #1.
DEBUG org.apache.fop.layoutmgr.AbstractPageSequenceLayoutManager -
page finished: 1, current num: 1
...
DEBUG org.apache.fop.area.AreaTreeHandler - *Pages rendered: 1*
DEBUG org.apache.fop.area.AreaTreeHandler - Avg render time:
11734ms/page (5pages/min)