Don't forget to set the content length.

Paulo

----- Original Message ----- 
From: "Daniel Essin" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, December 28, 2006 10:31 PM
Subject: [iText-questions] ByteArrayOutputStream


> I'm trying to use iTextSharp to work through the examples in Chapter 17 of 
> the
> book. The first example worked perfectly. The second example of writing to 
> the
> response object through a ByteArrayOutputStream fails. It fails because 
> Acrobat
> complains that the stream should begin %PDF-.
>
> By examining the contents of the stream in the debugger, the reason 
> becomes
> clear. The first character of the stream is a 7 instead of a %. I have no 
> clue
> why and would appreciate some guidance.
>
> The code is:
>                HttpResponse resp = this.Response;
>                Document document = new Document();
>                System.IO.MemoryStream baos = new MemoryStream();
>                PdfWriter.GetInstance(document, baos);
>                document.Open();
>                document.Add(new Paragraph("Hello World"));
>                document.Add(new 
> Paragraph(DateTime.Now.ToLongTimeString()));
>                document.Close();
>                resp.ContentType = "application/pdf";
>                resp.Write(baos.ToArray());
>                resp.Flush();
>
> Thank you,
> Dan Essin
>
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share 
> your
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> iText-questions mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/itext-questions
> Buy the iText book: http://itext.ugent.be/itext-in-action/ 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://itext.ugent.be/itext-in-action/

Reply via email to