Tech Off Post

Single Post Permalink

View Thread: ASP.NET and iTextSharp (free PDF Generator for .NET)
  • User profile image
    jh71283

    JBanta said:
    Filth said:
    *snip*
    You are trying to use iTextSharp in a web application so you can use ASP.NET's response stream directly to write the PDF.  Your code would look something like:

                this.Response.ContentType = "application/pdf";

                Document doc = new Document();

                PdfWriter writer = PdfWriter.GetInstance( doc, this.Response.OutputStream );

                try
                {
                    doc.Open();
                    doc.Add( new Paragraph( DateTime.Now.ToString() ) );
                    doc.Add( new Paragraph( "This is a test" ) );
                }
                finally
                {
                    doc.Close();
                    writer.Close();
                }
    You are resurrecting a thread over a yr old.

    Chances are the problem has been solved by now...