• Post Reply Bookmark Topic Watch Topic
  • New Topic

Apache FOP pdf geenration with XSL FO  RSS feed

 
siva krishna pallapu
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am new to XSLT FO and in one of requirements I need to generate the pdf from XSLT FO using Apache FOP. I was able to design the form with XSLT 1.0 and using Apache FOP 2.0 for generating pdf.

1. Below is the classpath I am setting
set classpath=.;D:/libs/barcode4j-2.1.jar;D:/libs/barcode4j-fop-ext-2.0.jar;D:/libs/avalon-framework-4_2_0.jar;D:/libs/commons-cli-1.0.jar;D:/fop-2.0-bin/fop-2.0/build/fop.jar;D:/libs/serializer-2.7.0.jar;D:/libs/xalan- 2.7.0.jar;D:/libs/xercesImpl-2.7.1.jar;D:/libs/xml-apis-1.3.04.jar;D:/libs/batik-all-1.7.jar;

2. command I am using to generate the pdf is : java -jar fop.jar -xml D:/json/person.xml -xsl D:/altova_xslt_file/Barcode4J_test.xslt -pdf D:/altova_xslt_file/Barcode4J_test.pdf

3. I am using the below names in the XSLT

xmlns:barcode="http://barcode4j.krysalis.org/ns" extension-element-prefixes="barcode"
4. Barcode generating piece
<fo:block>
<fo:instream-foreign-object>
<barcode:barcode xmlns:barcode="http://barcode4j.krysalis.org/ns" message="my message" orientation="90">
<barcode:code128>
<barcode:height>8mm</barcode:height>
</barcode:code128>
</barcode:barcode>
</fo:instream-foreign-object>
</fo:block>

5. Exception that I am getting is

D:\fop-2.0-bin\fop-2.0\build>java -jar fop.jar -xml D:/json/person.xml -xsl D:/altova_xslt_file/Barcode4J_test.xslt -pdf D:/altova_xslt_file/Barcode4J_test.pdf
Dec 12, 2015 11:10:18 AM org.apache.fop.fo.FOTreeBuilder fatalError
SEVERE: org.xml.sax.SAXParseException; systemId: file:/D:/altova_xslt_file/Barcode4J_test.xslt; lineNumber: 64; columnNumber: 66; javax.xml.transform.TransformerException: java.lang.ClassNotFoundExcep
tion: ns
Dec 12, 2015 11:10:18 AM org.apache.fop.cli.Main startFOP
SEVERE: Exception
org.apache.fop.apps.FOPException: javax.xml.transform.TransformerException: java.lang.ClassNotFoundException: ns
javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: java.lang.ClassNotFoundException: ns
at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:288)
at org.apache.fop.cli.InputHandler.renderTo(InputHandler.java:115)
at org.apache.fop.cli.Main.startFOP(Main.java:186)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.fop.cli.Main.startFOPWithDynamicClasspath(Main.java:143)
at org.apache.fop.cli.Main.main(Main.java:219)
Caused by: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: java.lang.ClassNotFoundException: ns
at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.processElement(ExtensionHandlerJavaPackage.java:491)
at org.apache.xalan.templates.ElemExtensionCall.execute(ElemExtensionCall.java:232)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1374)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1374)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1374)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1374)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1374)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1374)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1374)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
at org.apache.xalan.templates.ElemLiteralResult.execute(ElemLiteralResult.java:1374)
at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2411)
at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2281)
at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1367)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:709)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1284)
at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1262)
at org.apache.fop.cli.InputHandler.transformTo(InputHandler.java:285)
... 8 more
Caused by: javax.xml.transform.TransformerException: java.lang.ClassNotFoundException: ns
at org.apache.xalan.extensions.ExtensionHandlerJavaPackage.processElement(ExtensionHandlerJavaPackage.java:481)
... 32 more
Caused by: java.lang.ClassNotFoundException: ns
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)


Please help me in resolving the issue.

Thanks in Advance,
Siva
 
Vijitha Kumara
Bartender
Posts: 4002
42
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked whether you have all the required libraries included in the classpath?

Also it would be easier if you use something like Maven for build/run which would manage all the required dependencies for you.
 
g tsuji
Ranch Hand
Posts: 697
3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
set classpath=.;D:/libs/barcode4j-2.1.jar;D:/libs/barcode4j-fop-ext-2.0.jar;D:/libs/avalon-framework-4_2_0.jar;D:/libs/commons-cli-1.0.jar;D:/fop-2.0-bin/fop-2.0/build/fop.jar;D:/libs/serializer-2.7.0.jar;D:/libs/xalan- 2.7.0.jar;D:/libs/xercesImpl-2.7.1.jar;D:/libs/xml-apis-1.3.04.jar;D:/libs/batik-all-1.7.jar;

Looks good. Only problem is the space appeared in xalan- and 2.7.0.jar. I suppose that be a typo, though. (Besides, I would tempt to advise you update it to v2.7.1.)
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Siva, please BeForthrightWhenCrossPostingToOtherSites: http://www.altova.com/forum/default.aspx?g=posts&t=1100000943. Have you tried Irian's example code already?
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!