Apache fop java example

I'm trying to run this code in a Java servlet.
I got an error with the construction of fop object :

java.lang.NoSuchMethodError: org.apache.fop.fonts.FontInfo.setEventListener(Lorg/apache/fop/fonts/FontEventListener;)V org.apache.fop.fo.FOEventHandler.(FOEventHandler.java:89) org.apache.fop.area.AreaTreeHandler.(AreaTreeHandler.java:103) org.apache.fop.render.RendererFactory.createFOEventHandler(RendererFactory.java:358) org.apache.fop.fo.FOTreeBuilder.(FOTreeBuilder.java:99) org.apache.fop.apps.Fop.createDefaultHandler(Fop.java:147) org.apache.fop.apps.Fop.(Fop.java:82) org.apache.fop.apps.FopFactory.newFop(FopFactory.java:297)
Member 12033551 5-Oct-15 0:47

ssenorita 25-Apr-14 18:06
Would you provide the complete Java source code please ?
Sign in· View Thread
Member 10526524 15-Jan-14 10:56

Do you have the source code from the example?

modified 16-Jan-14 14:48pm. Member 10178733 29-Jul-13 18:35 pmamamul 9-Apr-13 2:02
Is there any idea Through Java and xsl-fo we can access database value in PDF
Sign in· View Thread
markdesign89 18-Jun-12 4:54
response.setContentLength(pdfBytes.length); response.setContentType("application/pdf"); response.addHeader("Content-Disposition", "attachment;filename=pdffile.pdf"); response.getOutputStream().write(pdfBytes); response.getOutputStream().flush();
Shyam S 18-Jun-12 18:11

sanjeevchaubey 1-Nov-11 22:25 Member 2352856 18-Aug-11 1:53

This code works well as a stand alone module but within an applet it breaks (see below):

------------------------------------------------------------------------------------------------------
javax.xml.transform.TransformerConfigurationException: Failed to compile stylesheet. 1 error detected.
at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:124)
at net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:125)
at net.sf.saxon.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:80)
at com.momaf.tiermuis.applet.health.StatementGeneratorApplet.getTransformer(Unknown Source)
at com.momaf.tiermuis.applet.health.StatementGeneratorApplet.genereateClientPDF(Unknown Source)
at com.momaf.tiermuis.applet.health.StatementGeneratorApplet.access$1200(Unknown Source)
at com.momaf.tiermuis.applet.health.StatementGeneratorApplet$4.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
java.lang.NullPointerException
at com.momaf.tiermuis.applet.health.StatementGeneratorApplet.genereateClientPDF(Unknown Source)
at com.momaf.tiermuis.applet.health.StatementGeneratorApplet.access$1200(Unknown Source)
at com.momaf.tiermuis.applet.health.StatementGeneratorApplet$4.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.awt.EventQueue$2.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
________________________________________________________________________________________

Do you know why?

Member 8275882 28-Sep-11 9:46

vicky00000 11-Jan-10 21:21

I am new to XML FO technique, and my requirement is to limit the pdf page to 2 and the remaining contend can lose. Is it possible.

is there any alternative to fo:float. pls share to me if u have any idea

cinamon 27-Jun-09 2:50
itext from Bruno Lowagie will blow this away and is easier to learn and use, and once you learn itext you can do way more then just creating pdfs from scratch. you can manipulate, fill, read forms, extract, combine pages..the list goes on and on
good effort, thanks
Sign in· View Thread
Tefik Becirovic 27-Jun-09 9:12

You have it right, concerning the generating of PDFs,
but this is only one link in a chain.

This article hasn’t to do with generating of PDFs only.

Here is the accent on a massive, automatical, datadriven creation of stylized PDFs,
and therefore is using of XSL-FO already right.

The question is a difficulty and broad unacceptability of this technology.
There are also other solutions, but not that much.

One of these you can find on www.winstom.com.

They offer you a simple GUI for document templates design
instead of difficult XSL-FO programming.

Member 8275882 28-Sep-11 9:55

I would not say iText is better than XSL-FO or the other way round, these are 2 different approaches for different scenarios. iText is for Java programmers and give you more flexibility however Apache FOP let's you create PDF files in a declarative manner (no programming required), and also give you programming language independance, since you could use the same XSL-FO file in different FOP processor. There are many commercial products like Oracle APEX that use XSF-FO for reporting.

And last but not least, if you do not want to learn XSL-FO, you can use a XSL-FO editor (WYSIWYG tool) like this one J4L FOP Designer