[prev in list] [next in list] [prev in thread] [next in thread] 

List:       fop-user
Subject:    Strange problem
From:       rajasekhar.cherukuri () tcs ! com
Date:       2005-05-18 7:33:52
Message-ID: OFE9DEF497.CAF599E9-ON65257005.0028594C-65257005.00287C21 () tcs ! com
[Download RAW message or body]

--=_alternative 00287BF965257005_=
Content-Type: text/plain; charset="US-ASCII"


> 
> Hi Team,
> 
> Following is the code that i am using for generating PDF
> Content using FOP of Apache. 
> When i have deployed this code on Windows machine and running from
> the 
> same machine, i am getting a prompt whether to Open the PDF or Save
> the 
> PDF (General Windows Feature........). Both Opening the PDF file at
> the 
> current location and Saving the file to Local hard disk are working
> fine. 
> But when i deployed the same code on Unix machine, and running it
> from 
> Windows machine, again i am getting prompt for "OPEN / SAVE" . This
> time 
> saving the file to local disk is working fine but i am unable to open
> the 
> file in the current location for viewing. It is giving " File can not
> be 
> opened " error. Is it the problem related to Operating System or can
> 
> anything be done through code ? Please help me out.
> 
> 
> 
> 
> 
> xslSourceName="newged.XSL"; 
> String xslPath = "";
> Source xmlSource = new
> StreamSource(new 
> StringReader(xmlData));
> Source xslSource = new 
> StreamSource(request.getSession().getServletContext
().getResourceAsStream("/xsl/"+xslSourceName));
> 
> 
> request.getSession(false).getServletContext().getResourceAsStream
("/WEB-INF/"+xslSourceName));
> 
> // Render with FOP
> ByteArrayOutputStream out = new 
> ByteArrayOutputStream();
> Driver driver = new Driver();
> 
> driver.setRenderer(Driver.RENDER_PDF);
> driver.setOutputStream(out);
> 
> // Do the transform and PDF rendering
> 
> directly to the destination output stream.
> Result result = new
> StreamResult(out);
> TransformerFactory tf = 
> TransformerFactory.newInstance();
> 
> Transformer transformer = 
> tf.newTransformer(xslSource); 
> 
> transformer.transform(xmlSource, new 
> SAXResult(driver.getContentHandler()));
> byte[] content =
> out.toByteArray();
> 
> 
> response.setContentLength(content.length);
> 
> response.getOutputStream().write(content);
> response.getOutputStream().flush();
> 
> 
> Thanks in Advance,
> Rajasekhar Cherukuri

Notice: The information contained in this e-mail message and/or attachments to it may \
contain confidential or privileged information.   If you are not the intended \
recipient, any dissemination, use, review, distribution, printing or copying of the \
information contained in this e-mail message and/or attachments to it are strictly \
prohibited.   If you have received this communication in error, please notify us by \
reply e-mail or telephone and immediately and permanently delete the message and any \
                attachments.  Thank you
--=_alternative 00287BF965257005_=
Content-Type: text/html; charset="US-ASCII"


<br><font size=2><tt>&gt; <br>
&gt; Hi Team,<br>
&gt; <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; Following is the code that i am using
for generating PDF<br>
&gt; Content using FOP of Apache. <br>
&gt; When i have deployed this code on Windows machine and running from<br>
&gt; the <br>
&gt; same machine, i am getting a prompt whether to Open the PDF or Save<br>
&gt; the <br>
&gt; PDF (General Windows Feature........). Both Opening the PDF file at<br>
&gt; the <br>
&gt; current location and Saving the file to Local hard disk are working<br>
&gt; fine. <br>
&gt; But when i deployed the same code on Unix machine, and running it<br>
&gt; from <br>
&gt; Windows machine, again i am getting prompt for &quot;OPEN / SAVE&quot;
. This<br>
&gt; time <br>
&gt; saving the file to local disk is working fine but i am unable to open<br>
&gt; the <br>
&gt; file in the current location for viewing. It is giving &quot; File
can not<br>
&gt; be <br>
&gt; opened &quot; error. Is it the problem related to Operating System
or can<br>
&gt; <br>
&gt; anything be done through code ? Please help me out.<br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; xslSourceName=&quot;newged.XSL&quot;; <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; String xslPath = &quot;&quot;;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Source xmlSource = new<br>
&gt; StreamSource(new <br>
&gt; StringReader(xmlData));<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Source xslSource = new &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp;<br>
&gt; StreamSource(request.getSession().getServletContext<br>
().getResourceAsStream(&quot;/xsl/&quot;+xslSourceName));<br>
&gt; &nbsp;<br>
&gt; &nbsp;<br>
&gt; request.getSession(false).getServletContext().getResourceAsStream<br>
(&quot;/WEB-INF/&quot;+xslSourceName));<br>
&gt; <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; // Render with FOP<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; ByteArrayOutputStream out = new <br>
&gt; ByteArrayOutputStream();<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Driver driver = new Driver();<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
&gt; driver.setRenderer(Driver.RENDER_PDF);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; driver.setOutputStream(out);<br>
&gt; &nbsp;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;// Do the transform and PDF rendering<br>
&gt; <br>
&gt; directly to the destination output stream.<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Result result = new<br>
&gt; StreamResult(out);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TransformerFactory tf = <br>
&gt; TransformerFactory.newInstance();<br>
&gt; &nbsp;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Transformer
transformer = <br>
&gt; tf.newTransformer(xslSource); <br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
&gt; transformer.transform(xmlSource, new <br>
&gt; SAXResult(driver.getContentHandler()));<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;byte[]
content =<br>
&gt; out.toByteArray();<br>
&gt; &nbsp;<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
&gt; response.setContentLength(content.length);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br>
&gt; response.getOutputStream().write(content);<br>
&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response.getOutputStream().flush();<br>
&gt; <br>
&gt; <br>
&gt; Thanks in Advance,<br>
&gt; Rajasekhar Cherukuri</tt></font>
<table><tr><td bgcolor=#ffffff><font color=#000000>Notice: The information contained \
in this e-mail message and/or attachments to it may contain confidential or \
privileged information.   If you are not the intended recipient, any dissemination, \
use, review, distribution, printing or copying of the information contained in this \
e-mail message and/or attachments to it are strictly prohibited.   If you have \
received this communication in error, please notify us by reply e-mail or telephone \
and immediately and permanently delete the message and any attachments.  Thank \
you<br> </font></td></tr></table>
--=_alternative 00287BF965257005_=--


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic