Hi there,
I have tried out a servlet to create a pdf file in memory using
ByteArrayOutputStream and it works fine.
In acrobat reader i cannot save or copy the document.
Is there any possibilty to save the document?
Following is the example coding i have used.
Thankx in advance
public class RonRptGen extends HttpServlet {
public void init( ServletConfig config ) throws ServletException {
super.init( config );
}
public void doGet( HttpServletRequest request, HttpServletResponse
response )
throws ServletException, IOException {
makePdf( request, response, "GET" );
}
protected void doPost( HttpServletRequest request, HttpServletResponse
response )
throws ServletException, IOException {
makePdf( request, response, "POST" );
}
public void makePdf( HttpServletRequest request, HttpServletResponse
response, String methodGetPost )
throws ServletException, IOException {
try {
Class.forName( sJdbcDriver );
Document document = new Document();
ByteArrayOutputStream baos = new
ByteArrayOutputStream();
PdfWriter.getInstance(document, baos);
document.open();
document.add(new Paragraph("BlaBla"));
document.close();
response.setHeader("Expires", "0");
response.setHeader("Cache-Control", "must-revalidate,
post-check=0, pre-check=0");
response.setHeader("Pragma", "public");
response.setContentType("application/pdf");
response.setContentLength(baos.size());
ServletOutputStream out = response. getOutputStream();
baos.writeTo(out);
out.flush();
out.close();
} catch (Exception e2) {
System.out.println("Error in " + getClass().getName() +
"\n" + e2);
}
}
private void error() {
}
}
Kind regards
Detlef Nebermann
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions