|
Hi, Does this help? Kristen Kristen Henry 303-883-0144 private void executeHttpResponse(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { DocumentException ex = null; ByteArrayOutputStream baosPDF = null; StringBuffer sbFilename; StringBuffer sbContentDispValue; ServletOutputStream sos; try { // Prepare PDF Output Stream (create the document) and assign to a ByteArrayOutputStream baosPDF = prepareBaosPDFOutputStream(); // Create a unique file name to put into the Header sbFilename = new StringBuffer(); sbFilename.append("filename_"); sbFilename.append(System.currentTimeMillis()); sbFilename.append(".pdf"); // Set the Cache control and application type in the Response resp.setHeader("Cache-Control", "max-age=30"); resp.setContentType("application/pdf"); // Set the file output to inline, and append filename sbContentDispValue = new StringBuffer(); sbContentDispValue.append("inline"); sbContentDispValue.append("; filename="); sbContentDispValue.append(sbFilename); // Set the Content Dispostion value in the Header and the Content Length resp.setHeader("Content-disposition", sbContentDispValue.toString()); resp.setContentLength(baosPDF.size()); // Write the prepared file out sos = resp.getOutputStream(); baosPDF.writeTo(sos); sos.flush(); } catch (DocumentException dex) { resp.setContentType("text/html"); PrintWriter writer = resp.getWriter(); writer.println(getClass().getName() + " caught an exception: " + dex.getClass().getName() + "<br>"); writer.println("<pre>"); dex.printStackTrace(writer); writer.println("</pre>"); } finally { if (baosPDF != null) baosPDF.close(); } } > -----Original Message----- > From: java400-l-bounces@xxxxxxxxxxxx > [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of Clapham, Paul > Sent: Wednesday, August 03, 2005 11:55 AM > To: Java Programming on and around the iSeries / AS400 > Subject: RE: Writing a PDF using iText against AS400 data... > > > You do this: > > 1. Create a PDF document. > 2. Return it as your servlet's response. > > Either of those two steps could cause the garbage. I think > you should test the two steps separately. > > PC2
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.