org.apache.fop.servlet
Class FopServlet
HttpServlet
org.apache.fop.servlet.FopServlet
public class FopServlet
extends HttpServlet
Example servlet to generate a PDF from a servlet.
Servlet param is:
- fo: the path to a XSL-FO file to render
or
- xml: the path to an XML file to render
- xslt: the path to an XSLT file that can transform the above XML to XSL-FO
Example URL: http://servername/fop/servlet/FopServlet?fo=readme.fo
Example URL: http://servername/fop/servlet/FopServlet?xml=data.xml&xslt=format.xsl
For this to work with Internet Explorer, you might need to append "&ext=.pdf"
to the URL.
$Id: FopServlet.java 513845 2007-03-02 17:11:41Z jeremias $
(todo) Ev. add caching mechanism for Templates objectsprotected static String | FO_REQUEST_PARAM - Name of the parameter used for the XSL-FO file
|
protected static String | XML_REQUEST_PARAM - Name of the parameter used for the XML file
|
protected static String | XSLT_REQUEST_PARAM - Name of the parameter used for the XSLT file
|
protected FopFactory | fopFactory - The FopFactory used to create Fop instances
|
protected SimpleLog | log - Logger to give to FOP
|
protected TransformerFactory | transFactory - The TransformerFactory used to create Transformer instances
|
protected URIResolver | uriResolver - URIResolver for use by this servlet
|
protected void | configureFopFactory() - This method is called right after the FopFactory is instantiated and can be overridden
by subclasses to perform additional configuration.
|
protected Source | convertString2Source(String param) - Converts a String parameter to a JAXP Source object.
|
void | doGet(HttpServletRequest request, HttpServletResponse response)
|
protected FOUserAgent | getFOUserAgent()
|
void | init()
|
protected void | render(Source src, Transformer transformer, HttpServletResponse response) - Renders an input file (XML or XSL-FO) into a PDF file.
|
protected void | renderFO(String fo, HttpServletResponse response) - Renders an XSL-FO file into a PDF file.
|
protected void | renderXML(String xml, String xslt, HttpServletResponse response) - Renders an XML file into a PDF file by applying a stylesheet
that converts the XML to XSL-FO.
|
FO_REQUEST_PARAM
protected static final String FO_REQUEST_PARAM
Name of the parameter used for the XSL-FO file
XML_REQUEST_PARAM
protected static final String XML_REQUEST_PARAM
Name of the parameter used for the XML file
XSLT_REQUEST_PARAM
protected static final String XSLT_REQUEST_PARAM
Name of the parameter used for the XSLT file
fopFactory
protected FopFactory fopFactory
The FopFactory used to create Fop instances
log
protected SimpleLog log
Logger to give to FOP
transFactory
protected TransformerFactory transFactory
The TransformerFactory used to create Transformer instances
uriResolver
protected URIResolver uriResolver
URIResolver for use by this servlet
configureFopFactory
protected void configureFopFactory()
This method is called right after the FopFactory is instantiated and can be overridden
by subclasses to perform additional configuration.
convertString2Source
protected Source convertString2Source(String param)
Converts a String parameter to a JAXP Source object.
param
- a String parameter
- Source the generated Source object
doGet
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException
javax.servlet.http.HttpServlet.doGet(HttpServletRequest, HttpServletResponse)
getFOUserAgent
protected FOUserAgent getFOUserAgent()
- a new FOUserAgent for FOP
init
public void init()
throws ServletException
javax.servlet.GenericServlet.init()
render
protected void render(Source src,
Transformer transformer,
HttpServletResponse response)
throws FOPException,
TransformerException,
IOException
Renders an input file (XML or XSL-FO) into a PDF file. It uses the JAXP
transformer given to optionally transform the input document to XSL-FO.
The transformer may be an identity transformer in which case the input
must already be XSL-FO. The PDF is written to a byte array that is
returned as the method's result.
src
- Input XML or XSL-FOtransformer
- Transformer to use for optional transformationresponse
- HTTP response object
renderFO
protected void renderFO(String fo,
HttpServletResponse response)
throws FOPException,
TransformerException,
IOException
Renders an XSL-FO file into a PDF file. The PDF is written to a byte
array that is returned as the method's result.
fo
- the XSL-FO fileresponse
- HTTP response object
renderXML
protected void renderXML(String xml,
String xslt,
HttpServletResponse response)
throws FOPException,
TransformerException,
IOException
Renders an XML file into a PDF file by applying a stylesheet
that converts the XML to XSL-FO. The PDF is written to a byte array
that is returned as the method's result.
xml
- the XML filexslt
- the XSLT fileresponse
- HTTP response object
Copyright 1999-2007 The Apache Software Foundation. All Rights Reserved.