The NullPointerException due to the fact that the code doesn't expect
that no ImageWriter for PNG is found. And that seems to be the case in
your environment. In a perfect world, you'd get a nice message that no
ImageWriter could be found, but that wouldn't help either in this case.
The question is why there's no ImageWriter. Maybe this php-java-bridge
you use does something weird when setting up the classpath. I don't have
any other explanation because the internal PNG writer is in the
xmlgraphics-commons.jar which is obviously there (ImageWriterRegistry
itself seems to work) but the "Service" class cannot discover the
plug-in files in the META-INF directory.

Don't know how to help here without knowing about PHP and
php-java-bridge. Maybe someone else can help.

You asked about an example for multiple PNG files. I attached one which
runs fine on my side.

On 08.11.2006 13:08:01 Olivier Mansour wrote:
> 
> Le 8 nov. 06 à 09:42, Olivier Mansour a écrit :
> 
> >
> > Le 6 nov. 06 à 14:55, Jeremias Maerki a écrit :
> >
> >> Creating multiple PNG files is only supported if output is done to a
> >> file (seems to be the case here). In this case, you have to set the
> >> output file on the user agent in addition to the output stream:
> >>
> >> useragent.setOutputFile(new File("D:/out.png"));
> >
> > I have added this line after getting my user agent (with  
> > newFOUserAgent()) :
> >
> > $file_out = new Java ('java.io.File', $path_to_png);
> > $fop_ua->setOutputFile($file_out);
> >
> > I have now an error on my transform action :
> > java.lang.Exception: Invoke failed: [o(TransformerImpl)]->transform 
> > ((Source)o(StreamSource), (Result)o(SAXResult)). Cause:  
> > javax.xml.transform.TransformerException:  
> > java.lang.NullPointerException Responsible VM: [EMAIL PROTECTED]:// 
> > java.sun.com/ at  
> > com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform 
> > (TransformerImpl.java:651) at  
> > com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform 
> > (TransformerImpl.java:281) at  
> > sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at  
> > sun.reflect.NativeMethodAccessorImpl.invoke 
> > (NativeMethodAccessorImpl.java:39) at  
> > sun.reflect.DelegatingMethodAccessorImpl.invoke 
> > (DelegatingMethodAccessorImpl.java:25) at  
> > java.lang.reflect.Method.invoke(Method.java:585) at  
> > php.java.bridge.JavaBridge.Invoke(JavaBridge.java:1073) at  
> > php.java.bridge.Request.handleRequest(Request.java:499) at  
> > php.java.bridge.Request.handleRequests(Request.java:544) at  
> > php.java.bridge.JavaBridge.run(JavaBridge.java:178) at  
> > php.java.bridge.BaseThreadPool$Delegate.run(BaseThreadPool.java:37)  
> > Caused by: javax.xml.transform.TransformerException:  
> > java.lang.NullPointerException ... 11 more Caused by:  
> > java.lang.NullPointerException at  
> > org.apache.fop.render.bitmap.PNGRenderer.stopRenderer 
> > (PNGRenderer.java:123) at  
> > org.apache.fop.area.RenderPagesModel.endDocument 
> > (RenderPagesModel.java:240) at  
> > org.apache.fop.area.AreaTreeHandler.endDocument 
> > (AreaTreeHandler.java:357) at  
> > org.apache.fop.fo.FOTreeBuilder.endDocument(FOTreeBuilder.java:170)  
> > at  
> > com.sun.org.apache.xml.internal.serializer.ToXMLSAXHandler.endDocument 
> > (ToXMLSAXHandler.java:182) at  
> > com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endDocume 
> > nt(AbstractSAXParser.java:769) at  
> > com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.endEnti 
> > ty(XMLDocumentScannerImpl.java:560) at  
> > com.sun.org.apache.xerces.internal.impl.XMLEntityManager.endEntity 
> > (XMLEntityManager.java:1779) at  
> > com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.load 
> > (XMLEntityScanner.java:1758) at  
> > com.sun.org.apache.xerces.internal.impl.XMLEntityScanner.skipSpaces 
> > (XMLEntityScanner.java:1274) at  
> > com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl 
> > $TrailingMiscDispatcher.dispatch(XMLDocumentScannerImpl.java:1247)  
> > at  
> > com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl 
> > .scanDocument(XMLDocumentFragmentScannerImpl.java:368) at  
> > com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse 
> > (XML11Configuration.java:834) at  
> > com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse 
> > (XML11Configuration.java:764) at  
> > com.sun.org.apache.xerces.internal.parsers.XMLParser.parse 
> > (XMLParser.java:148) at  
> > com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse 
> > (AbstractSAXParser.java:1242) at  
> > com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform 
> > Identity(TransformerImpl.java:560) at  
> > com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform 
> > (TransformerImpl.java:642) ... 10 more
> >
> >
> 
> someone has an example of code used to transform a FO file to several  
> png files with FOP ? I'am a bit confused right now ;-)
> 
> Thank you
> Olivier
> 
> >
> > an idea ?
> >
> >>
> >> HTH
> >>
> >> On 04.11.2006 18:00:09 Olivier Mansour wrote:
> >>> Hey
> >>>
> >>>
> >>> Another beginner question
> >>>
> >>> I use fop 0.92 but I'am consedreing moving to trunk soon
> >>>
> >>> I tried to generate png from a fo file
> >>>
> >>> using command line works fine :
> >>>   java -jar fop.jar -fo /tmp/test.fo -png ../../../web/uploads/ 
> >>> test.png
> >>>
> >>> give severals png test.png, test2.png - one png for each page.
> >>>
> >>> I am now trying using the API trought php-java-bridge (quite similar
> >>> if we where using java)
> >>>
> >>> here my code :
> >>>
> >>>         // Instanciate & configure FOP user agent
> >>>                $fop_factory = new JavaClass
> >>> ('org.apache.fop.apps.FopFactory');
> >>>                $fop_factory = $fop_factory->newInstance();
> >>>                $fop_factory->setUserConfig(new Java('java.io.File',
> >>> sfConfig::get('sf_app_config_dir').'/fop.xconf'));
> >>>                $fop_ua = $fop_factory->newFOUserAgent();
> >>>
> >>>                 /*
> >>>                 * Setup output stream.  Note: Using  
> >>> BufferedOutputStream
> >>>                 * for performance reasons (helpful with
> >>> FileOutputStreams).
> >>>                 */
> >>>                $out = new Java('java.io.FileOutputStream',
> >>> $path_to_png);
> >>>                $out = new Java('java.io.BufferedOutputStream',  
> >>> $out);
> >>>
> >>>                // Construct fop with desired output format
> >>>                $fop_mime_constants = new JavaClass
> >>> ('org.apache.fop.apps.MimeConstants');
> >>>                $fop = $fop_factory->newFop($fop_mime_constants-
> >>>> MIME_PNG, $fop_ua, $out);
> >>>
> >>>                // Setup JAXP using identity transformer
> >>>                $transformer_factory = new JavaClass
> >>> ('javax.xml.transform.TransformerFactory');
> >>>                $transformer_factory = $transformer_factory-
> >>>> newInstance();
> >>>                $transformer = $transformer_factory->newTransformer 
> >>> ();
> >>>
> >>>                // Setup input stream
> >>>                $src = new Java
> >>> ('javax.xml.transform.stream.StreamSource', $path_to_fo);
> >>>
> >>>                // Resulting SAX events (the generated FO) must be
> >>> piped through to FOP
> >>>                $res = new Java('javax.xml.transform.sax.SAXResult',
> >>> $fop->getDefaultHandler());
> >>>
> >>>                // Start XSLT transformation and FOP processing
> >>>                $transformer->transform($src, $res);
> >>>
> >>> the problem is just the first png is generated  ! :-(
> >>>
> >>> An idea ?
> >>>
> >>> Thank you for your advices and making fop wich is great


Jeremias Maerki

Attachment: ExampleFO2MultiPNG.java
Description: Binary data

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

Reply via email to