|
Hi, I use the following code to generate my pdf in a servlet.
There are two problems here: 1. I see the file in the directory but when I access it, it
gives me Sharing Violation error. If I logout of my Form Based Authentication
implemented (Servlet is in that system) system I am able to access the pdf
correctly. Does anybody know how I can release the file once the file has been
generated 2. After getting the FileOutputStream it starts writing to
the file. At the same time it generates a “socket connection reset by
peer exception”. I don’t know why this exception is generated. It
might be with the popup window which closes down after passing the information
to a servlet which in turn dispatches the below servlet to generate the pdf Any help is appreciated Thank you Jignesh public void
renderXML(Document xmlsource, InputStream xslobj, String file_is) throws ServletException { FileOutputStream fout = null;
System.getProperty("file.separator"); String sep =
System.getProperty("file.separator"); File dir = new
File("c:" + sep + "Email PDF");
if(!dir.exists()) {
dir.mkdirs(); }
System.out.println("New File Dir is : " + dir); File file = new
File(dir,file_is); try { fout = new FileOutputStream(file); }
catch(IOException ioe) {
ioe.printStackTrace(); } try {
Driver driver = new Driver();
driver.setLogger(log); driver.setOutputStream(fout);
driver.setRenderer(Driver.RENDER_PDF);
Transformer
transformer=TransformerFactory.newInstance().newTransformer(new
StreamSource(xslobj));
transformer.transform(new JDOMSource(xmlsource), new
SAXResult(driver.getContentHandler()));
fout.flush(); if (fout !=null) fout.close(); } catch
(Exception ex) { ex.printStackTrace(); } } |
- Re: Need help with PDF File creation Jignesh Shah
- Re: Need help with PDF File creation J.Pietschmann
