Created
August 21, 2017 07:39
-
-
Save mindc/ac2ab6f40421421fa3525230fae629fc to your computer and use it in GitHub Desktop.
Custom userconf.xml for Apache FOP on Tomcat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- FopServlet.java.org 2010-07-12 21:34:45.000000000 +0200 | |
+++ FopServlet.java 2011-04-06 19:00:01.639060332 +0200 | |
@@ -44,6 +44,10 @@ import org.apache.fop.apps.Fop; | |
import org.apache.fop.apps.FopFactory; | |
import org.apache.fop.apps.MimeConstants; | |
+import org.xml.sax.SAXException; | |
+import org.apache.commons.logging.Log; | |
+import org.apache.commons.logging.LogFactory; | |
+ | |
/** | |
* Example servlet to generate a PDF from a servlet. | |
* | |
@@ -77,6 +81,8 @@ public class FopServlet extends HttpServ | |
/** Name of the parameter used for the XSLT file */ | |
protected static final String XSLT_REQUEST_PARAM = "xslt"; | |
+ private final Log log = LogFactory.getLog(FopServlet.class); | |
+ | |
/** The TransformerFactory used to create Transformer instances */ | |
protected TransformerFactory transFactory = null; | |
/** The FopFactory used to create Fop instances */ | |
@@ -94,6 +100,13 @@ public class FopServlet extends HttpServ | |
//Configure FopFactory as desired | |
this.fopFactory = FopFactory.newInstance(); | |
this.fopFactory.setURIResolver(this.uriResolver); | |
+ try { | |
+ fopFactory.setUserConfig(new File("userconf.xml")); | |
+ } catch (IOException e) { | |
+ log.error("No such file or directory", e); | |
+ } catch (SAXException e) { | |
+ throw new ServletException(e); | |
+ } | |
configureFopFactory(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment