Download - Apache Fop
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 1
Overview
FOP in ApacheAngus Liu, MIS
Dec. 2007
提示:会议将于开始请把您的手机调成振动或者暂时关机! Thank you
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 2
Agenda
XSL and XSL-FO (5min)
FOP Introduction (5min)
Using FOP (15min)
Demo (10min)
FOP in Web Application (10min)
QA (5min)
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 3
XSL and FO XSL in XML
XSLT (v1.0 v2.0)
XSL-FO (v1.0 v1.1)
XPath (v1.0 v2.0)
XQuery (v1.0)
FO = Formatting Objects
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 4
FO Product
FOP
Open Source Project
We using FOP in our project to print Order as a PDF document and will send it to customer or customer can sign by E-Sign system.
RenderX XEP
Business Product
http://www.renderx.com/tools/xep.html
X2P
Business Product
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 5
FOP Introduction
Formatting Objects Processor
It’s a sub-project under XML Graphics Project in Apache
Version
0.20.5 (WebEx Modified) We using this version in our project.
0.93
0.94 (the last version)
Download
http://xmlgraphics.apache.org/fop/index.html
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 6
Using FOP
Fop.jar
Other jars
avalon-framework-4.2.0.jar
batik-all-1.6.jar
commons-io-1.3.1.jar
commons-logging-1.0.4.jar
serializer-2.7.0.jar
xalan-2.7.0.jar (XSLT Processor)
xercesImpl-2.7.1.jar
xml-apis-1.3.02.jar
xmlgraphics-commons-1.2.jar
Another sub project under Apache Graphic project
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 7
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 8
Package & Classes
V0.94
Package
–org.apache.fop.apps
Classes
–MimeConstants
–FOPException
–FOPFactory
–FOPUserAgent
–FOP
V0.20.5
Package
–org.apache.fop.apps
Classes
–Driver
–FOPException
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 9
Support File Type
org.apache.fop.apps.MimeConstants
Output File Type
PDF POSTSCRIPT EPS PCL PCL_ALT
AFP AFP_ALT PLAIN_TEXT RTF RTF_ALT1
RTF_ALT2 MIF SVG GIF PNG
JPEG TIFF XSL_FO
FOP_AWT_PREVIE
FOP_PRINT
FOP_AREA_TREE
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 10
Sample CodeFopFactory fopFactory = FopFactory.newInstance();
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
OutputStream out = new java.io.FileOutputStream(pdffile);
out = new java.io.BufferedOutputStream(out);
try {
// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(new StreamSource(xsltfile));
// Set the value of a <param> in the stylesheet
transformer.setParameter("versionParam", "2.0");
// Setup input for XSLT transformation
Source src = new StreamSource(xmlfile);
// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
// Start XSLT transformation and FOP processing
transformer.transform(src, res);
} finally {
out.close();
}
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 11
Demo
Platform
–Eclipse 3.3 (Europa)
–JDK 5.0 (1.5.0_13)
–FOP 0.94
OMS Sample (View WebEx Order Form Sample)
Hello World!
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 12
FOP in Web Application
http://127.0.0.1:8080/FOPSample
Convert the result data to ByteStream
Multilanguage problem
–East Asia font support (Chinese, Korean, Japanese)
–Different PDF Language based on different location
stxx plugin for Struts framework
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 13
Q&A
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 14
Reference
http://xmlgraphics.apache.org/fop/
http://www.w3.org/TR/xsl/
http://www-128.ibm.com/developerworks/cn/
Email: [email protected]: [email protected]
© 2006 Cisco Systems, Inc. All rights reserved. Cisco ConfidentialPresentation_ID 15