You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ar...@sifycorp.com on 2002/02/14 11:26:00 UTC
ActionServlet return a pdf document
Hello,
I am trying to generate a PDF document on the fly based on dynamic jsp
generation comming from BroadVision.
I am making use of an struts action class,which genreates the required PDf
file.When i try to open the PDF file I get the error as
"There was an error opening this document.Could not repair this file"
If i run the same application in Tomcat it works fine.
This is by java code.
public class PDF extends Action
{
public ActionForward perform(ActionMapping mapping, ActionForm
form,HttpServletRequest request,HttpServletResponse response) throws
IOException, ServletException
{
try
{
Document document = new Document();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
document.open();
document.add(new Paragraph("Hello World"));
document.close();
response.setContentType("application/pdf");
response.setContentLength(baos.size());
ServletOutputStream out = response.getOutputStream();
baos.writeTo(out);
out.flush();
}
catch (Exception e2)
{
System.out.println("Error in "+getClass().getName()+"\n"+e2);
}
return null;
}
}//end of class
Please look into this matter.
Thanks & regards
Arun
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>