Hi,
I have implemented FOP on an tomcat 5 servlet. The XML data is read from Oracle
10g to a java.lang.String and then mixed with XSLT from the file system to
produce the PDF. Once I start the tomcat server and run the servlet all is good
and the PDF is produced correctly. When I run the servlet again I get a "File
does not begin with '%PDF-" error. This error repeats until I restart the
tomcat server. The error in the tomcat log is
[INFO] ERROR: The processing instruction target matching "[xX][mM][lL]" is not
allowed.
I've research this error and it points to white space before the
<?xml version="1.0" encoding="UTF-8">
line in the XML but this seems not to be the case.
Any ideas where to look next??
Thanks in advance, Ian.
ByteArrayOutputStream out = new ByteArrayOutputStream();
org.apache.fop.configuration.Configuration.put("baseDir",
"C:\\Program Files\\Apache Software Foundation\\Tomcat
5.0\\webapps\\GPS");
response.setContentType("application/pdf");
response.setHeader("Accept-Ranges", "bytes");
logger.info("xslParam : " + xslParam);
logger.info("xmlParam : " + xmlParam);
Source xslSrc = new StreamSource(new File(xslParam));
// Construct driver
Driver driver = new Driver();
driver.setLogger(logger);
driver.setRenderer(Driver.RENDER_PDF);
driver.setOutputStream(out);
//Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(xslSrc);
//Setup input for XSLT transformation
Source xmlSrc = new StreamSource(new StringReader(xmlParam));
//Resulting SAX events (the generated FO) must be piped through to
FOP
Result res = new SAXResult(driver.getContentHandler());
//Start XSLT transformation and FOP processing
transformer.transform(xmlSrc, res);
//Send content to Browser
response.getOutputStream().write(out.toByteArray());
response.flushBuffer();