I was using 0.93 successfully some time ago, and I have another
application to use,
so I downloaded 0.94.
I am using Java 1.5.0_11
I tried to set things up correctly, but the PDF I generated can't be
read by Adobe Reader 8. I get a message that the file has been damaged
and can't be repaired.
I have some code that reads a source document, builds an Fop from a
FopFactory using MimeConstants.MIME_PDF and an OutputStream. I build a
Transformer from a TransformerFactory using an XSLT file, get a
SAXResult from the fop, and then transform the source into the result.
I have tried a very simple style sheet but no success.
Can anyone help me understand what is wrong, or point me to a basic
example that will work with the new version?
Here is the code:
DocumentBuilderFactory dbf =
DocumentBuilderFactory.newInstance();
DocumentBuilder db = null;
Document input = null;
try {
db = dbf.newDocumentBuilder();
input = db.parse(new
File("input/astruct/primitives/System.xml"));
} catch (ParserConfigurationException e) { e.printStackTrace();
} catch (SAXException e) { e.printStackTrace();
} catch (IOException e) { e.printStackTrace(); }
Source src = new DOMSource(input);
FopFactory fopFactory = FopFactory.newInstance();
OutputStream out = null;
File outputDir = new File("output");
File outputFile = new File(outputDir, "System.pdf");
try {
out = new BufferedOutputStream(new
FileOutputStream(outputFile));
} catch (FileNotFoundException e) {e.printStackTrace();}
Fop fop = null;
try {
fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
} catch (FOPException e) { e.printStackTrace(); }
File xsltFile = new File("xslt/module-fo.xslt");
TransformerFactory trFactory = TransformerFactory.newInstance();
Transformer transformer = null;
try {
transformer = trFactory.newTransformer(new
StreamSource(xsltFile));
} catch (TransformerConfigurationException e)
{e.printStackTrace();}
Result res = null;
try {
res = new SAXResult(fop.getDefaultHandler());
} catch (FOPException e) { e.printStackTrace(); }
try {
transformer.transform(src, res);
} catch (TransformerException e) { e.printStackTrace();}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]