What happens when you invoke the servlet through the browser? Also, does it happen to work properly using a different browser?
-Matt --- Uwe Kristmann <[EMAIL PROTECTED]> wrote: > > hi, > > first to say, i'm not a great java expert and new > to itext . > > I'm trying to write pdfcontent direct to the > browser (MSIE 6.026) . > It works fine for <document.add>, but using > <PdfContentbyte> has > no effect. > Writing to the servers filesystem and redirecting > the generated file > to the client is ok, but i would prefer to write > to a ByteArrayOutputStream. > > has anyone an idea what's wrong with this code? > > thanks a lot > > uwe > > serverlog: > with PdfContentByte > [20/06/2003 19:43:44:290 GMT+02:00] StreamTest3: > init > [20/06/2003 19:43:46:793 GMT+02:00] StreamTest3: > BAOS.size()= 2074 > [20/06/2003 19:43:46:893 GMT+02:00] StreamTest3: > BAOS.size()= 2074 > [20/06/2003 19:45:53:115 GMT+02:00] StreamTest3: > destroy > without > [20/06/2003 19:45:53:165 GMT+02:00] StreamTest3: > init > [20/06/2003 19:45:55:518 GMT+02:00] StreamTest3: > BAOS.size()= 1916 > [20/06/2003 19:45:55:619 GMT+02:00] StreamTest3: > BAOS.size()= 1916 > > //package pdfservlet; > //////////////////////////////////////////////////////////////////////////////// > import java.io.ByteArrayOutputStream; > import java.io.FileOutputStream; > import java.io.IOException; > import java.net.URL; > > import javax.servlet.http.*; > import javax.servlet.*; > > import com.lowagie.text.*; > import com.lowagie.text.pdf.BaseFont; > import com.lowagie.text.pdf.PdfContentByte; > import com.lowagie.text.pdf.PdfWriter; > //////////////////////////////////////////////////////////////////////////////// > public class StreamTest3 extends HttpServlet { > //////////////////////////////////////////////////////////////////////////////// > > public void init(ServletConfig config) > throws ServletException { > super.init(config); > } > //////////////////////////////////////////////////////////////////////////////// > > public void doGet > ( > HttpServletRequest req, > HttpServletResponse res > ) > throws > ServletException, > IOException > { doPost(req,res); } > //////////////////////////////////////////////////////////////////////////////// > > public void doPost(HttpServletRequest request, > HttpServletResponse response) > throws IOException, ServletException { > > Document document = new Document(PageSize.A4, 50, > 50, 50, 50); > ByteArrayOutputStream baos = new > ByteArrayOutputStream(); > try { > PdfWriter writer = > PdfWriter.getInstance(document,baos); > writer.getInstance(document,baos); > document.open(); > /* > PdfContentByte cb = writer.getDirectContent(); > > cb.beginText(); > > BaseFont bf = > BaseFont.createFont(BaseFont.HELVETICA, > BaseFont.CP1252, BaseFont.NOT_EMBEDDED); > > cb.setFontAndSize(bf, 12); > String text = "Sample text for > alignment"; > // we show some text starting on some > absolute position with a given alignment > > cb.showTextAligned(PdfContentByte.ALIGN_CENTER, text > + " Center", 250, 700, 0); > > cb.showTextAligned(PdfContentByte.ALIGN_RIGHT, text > + " Right", 250, 650, 0); > > cb.showTextAligned(PdfContentByte.ALIGN_LEFT, text + > " Left", 250, 600, 0); > > // we draw some text on a certain > position > cb.setTextMatrix(100, 400); > cb.showText("Text at position > 100,400."); > > // we draw some rotated text on a > certain position > cb.setTextMatrix(0, 1, -1, 0, 100, 300); > cb.showText("Text at position 100,300, > rotated 90 degrees."); > > // we draw some mirrored, rotated text > on a certain position > cb.setTextMatrix(0, 1, 1, 0, 200, 200); > cb.showText("Text at position 200,200, > mirrored and rotated 90 degrees."); > > // we tell the contentByte, we've > finished drawing text > cb.endText(); > */ > document.add(new Chunk("HELLO STREAMTEST > 3!!")); > document.close(); > > } > catch (DocumentException de) > {log(de.getMessage());} > > 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()); > log(String.valueOf("BAOS.size()= > "+String.valueOf(baos.size()))); > > ServletOutputStream out = > response.getOutputStream(); > baos.writeTo(out); > out.flush(); > } > } > > > ______________________________________________________________________________ > UNICEF bittet um Spenden fur die Kinder im Irak! > Hier online an > UNICEF spenden: > https://spenden.web.de/unicef/special/?mc=021101 > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: INetU > Attention Web Developers & Consultants: Become An > INetU Hosting Partner. > Refer Dedicated Servers. We Manage Them. You Get 10% > Monthly Commission! > INetU Dedicated Managed Hosting > http://www.inetu.net/partner/index.php > _______________________________________________ > iText-questions mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/itext-questions __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com ------------------------------------------------------- This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php _______________________________________________ iText-questions mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/itext-questions