Hi,
I do as follow. But I get error message like: "Could not find Acrobat External
Window Handler."
Can someone help?
Thanks!
Thomas...
...
public String showPDF()
{
ServletOutputStream out = null;
FacesContext context = FacesContext.getCurrentInstance();
HttpServletResponse response = (HttpServletResponse)
context.getExternalContext().getResponse();
File pdfFile = new File("c:\\temp\\Protokol.pdf");
response.setContentType("application/pdf");
byte[] bytes = new byte[(int)pdfFile.length()]; // read you PDF from
file here
response.setContentLength(bytes.length);
try {
out = response.getOutputStream();
out.write(bytes, 0, bytes.length);
} catch (IOException ex) {
} finally {
try {
out.flush();
out.close();
} catch (IOException ex) { }
}
FacesContext.getCurrentInstance().responseComplete();
return null;
}
...
"Levin, Stan" <[EMAIL PROTECTED]> schrieb: Hi Thomas,
We it do as following:
ServletOutputStream out = null;
HttpServletResponse response = FacesUtils.getServletResponse();
response.setContentType("application/pdf");
byte[] bytes = // read you PDF from file here
response.setContentLength(bytes.length);
try {
out = response.getOutputStream();
out.write(bytes, 0, bytes.length);
} catch (IOException ex) {
} finally {
try {
out.flush();
out.close();
} catch (IOException ex) { }
}
facesContext.responseComplete();
Regards,
Stan.
---------------------------------
From: Thomas Chang [mailto:[EMAIL PROTECTED]
Sent: Monday, January 29, 2007 3:48 PM
To: MyFaces Discussion
Subject: A question about showing/opening PDF-file in run-time
Good day everybody,
My code look as follow. What I want to do is: I generate a pdf-file in
run-time and put it under a dir in server-side, assumed under
"c:\temp\myfile.pdf". If one clicks the commmanlink, the PDF-file will be
opened in a new browser window with tool-bar which contains save, print etc.
My code look as follow. And I want to know how can I write the function
showPDF() in my backing bean.
Or one can do this in an other way?
Thanks
Thomas
myJSF.xhtml
*************
...
<t:commandLink id="csvDownload" value="File download"
action="#{fileBean.showPDF }" immediate="true"></t:commandLink>
...
MyBean.java
*************
...
showPDF(){
...
}
...
---------------------------------
NEU: Fragen stellen - Wissen, Meinungen und Erfahrungen teilen. Jetzt auf
Yahoo! Clever.
==============================================================================
Please access the attached hyperlink for an important electronic communications
disclaimer:
http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
==============================================================================
---------------------------------
Besseren Schutz gegen Spam - jetzt bei dem neuen Yahoo! Mail .
---------------------------------
Der neue Internet Explorer 7 in deutscher Ausführung ist da!