Hi,
I am using iTextSharp to create a PDF doc and when I try to add a page I get an Acrobat Reader error error "The file is damaged and could not be repaired."
My code:
*******************************
// step 1
// need to write to memory first due to IE wanting // to know the length of the pdf beforehandMemoryStream m =
new MemoryStream();Document document =
new Document(); try{
// step 2: we set the ContentType and create an instance of the WriterResponse.ContentType = "application/pdf";
PdfWriter.GetInstance(document, m);
// step 3document.Open();
// step 4document.Add(
new Paragraph(DateTime.Now.ToString()));document.NewPage();
document.Add(
new Paragraph("Hello World"));catch (DocumentException ex)
{
Console.Error.WriteLine(ex.StackTrace);
Console.Error.WriteLine(ex.Message);
}
// step 5: Close document
document.Close();
// step 6: Write pdf bytes to outputstreamResponse.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length);
Response.OutputStream.Flush();
Response.OutputStream.Close();
*******************************
Could you help please
Thanks,
Vijit
Yahoo! Sports
Rekindle the Rivalries. Sign up for Fantasy Football
