Aravinda:
Enclosed is a class I wrote that extends Turbine's RawScreen to display pdf
files. If you can create your pdf stream as a ByteArrayOutputStream then
the following will work "as-is" for you. Simply extend this ADT and build
your pdf stream in a buildPDF method, returning a ByteArrayOutputStream.
Even if it doesn't work for you, maybe it will help.
Steve
public abstract class PdfScreen extends
org.apache.turbine.modules.screens.RawScreen
{
/**
* Set the content type to Pdf. (see RawScreen)
*
* @param data Turbine information.
* @return content type.
*/
public String getContentType(RunData data)
{
return "application/pdf";
};
/**
* Classes that implement this ADT must override this to build the pdf
file.
*
* @param data RunData
* @return ByteArrayOutputStream
* @exception Exception, any old exception.
*/
protected abstract ByteArrayOutputStream buildPdf (RunData data) throws
Exception;
/**
* Overrides & finalizes doOutput in RawScreen to serve the output stream
created in buildPDF.
*
* @param data RunData
* @exception Exception, any old generic exception.
*/
protected final void doOutput(RunData data) throws Exception
{
ByteArrayOutputStream baos = buildPdf(data);
if (baos != null)
{
HttpServletResponse response = data.getResponse();
//We have to set the size to workaround a bug in IE (see
com.lowagie iText FAQ)
data.getResponse().setContentLength(baos.size());
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
}
else
{
throw new Exception("output stream from buildPDF is null");
}
}
}
-----Original Message-----
From: Aravinda Addala [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 31, 2002 3:59 AM
To: TurbineDev
Subject: Please help. Content type: Sending pdf content to the browser
Hi,
I have read several postings about sending a different content to the
browser. I am trying to generate a pdf using FDF in my action. I get the
content displayed as plain text. I tried many ways ( I had set the content
type both in Response and RunData objects in my action. Also tried to use
data.setContentType in the template. Nothing worked). The same code works
fine if I use that in a Servlet outside turbine.
I am using turbine 3.
Please help.
Thanks in advance.
Aravinda
--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>