But where I don't agree with your Mr. Matt Benson for the third point. IT IS MANDATORY to set the content type and many real browser WILL NOT DISPLAY anything if it is not set.
In the same way, try to deliver a 1kb (very small file) PDF file to any browser with the Adobe Acrobat PDF plug-in (I doubt that any plugin will work) and you will see that IT WON'T WORK, because the buffer is not full enough to be sent to the client (aka IE, Mozilla, Safari or whatever).
Hubert
From: Matt Benson <[EMAIL PROTECTED]> To: Hubert Lingo <[EMAIL PROTECTED]> CC: itext-questions <[EMAIL PROTECTED]> Subject: Re: Re: [iText-questions] Newbie's prob Date: Tue, 24 Jun 2003 07:50:54 -0700 (PDT)
That's wonderful, but
1) You didn't stay on the list 2) I'm not the one with the problem, and 3) Since the original poster is seeing some content, I'm not sure that these servlet suggestions, though worth keeping in mind at all times, will help in this specific situation.
best regards, Matt
--- Hubert Lingo <[EMAIL PROTECTED]> wrote: > When you write something with a servlet do not > forget in some situations to > either: > - set the content length (with > response.setContentLength(data.length); > response.getOutputStream().write(data);) before > writing. Probably your > problem! > - to flush the writer. > > Hubert > > > >From: Matt Benson <[EMAIL PROTECTED]> > >To: Uwe Kristmann <[EMAIL PROTECTED]> > >CC: itext-questions > <[EMAIL PROTECTED]> > >Subject: Re: Re: [iText-questions] Newbie's prob > >Date: Mon, 23 Jun 2003 07:10:11 -0700 (PDT) > > > >Always keep the list on correspondences. I would > >think the problem lies in your usage of the > >PdfContentByte, and not to pass the buck, but I'll > bet > >Paulo knows. :) > > > >-Matt > > > > > >--- Uwe Kristmann <[EMAIL PROTECTED]> wrote: > > > hi matt, > > > > > > it works, i get the pdfstream with the text > > > HELLO StreamTest3!! (document.add) > > > but not the text i tried to add with > > > PdfContentbyte. > > > both in MSIE 6.0.26 > > > and > > > Mozilla/5.0 (Windows; U; Windows NT 5.1; > de-DE; > > > rv:1.0.2) Gecko/20021120 Netscape/7.01 > > > don't understand why > > > thanks for the reply > > > > > > uwe > > > > > > Matt Benson <[EMAIL PROTECTED]> schrieb am > > > 20.06.03 19:02:15: > > > > > > > > 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, > === message truncated ===
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
_________________________________________________________________
MSN Messenger : discutez en direct avec vos amis ! http://www.msn.fr/msger/default.asp
------------------------------------------------------- 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