Tech Off Post

Single Post Permalink

View Thread: ASP.NET and iTextSharp (free PDF Generator for .NET)
  • Jack Dong .NET

    Filth said:

    Hi,

    I've just starting using iTextSharp in a code behind page, but when I run it, it just shows a empty pdf.

    I was wondering if anyone could see anything crazy that I have or haven't done?

    The code in my page_load event is:

    MemoryStream m = new MemoryStream();

    Document document = new Document(PageSize.A4.Rotate(), 10, 10, 10, 10);

    try

    {

    Response.ContentType = "application/pdf";

    PdfWriter.GetInstance(document, m);

    document.Open();

    document.Add(new Paragraph(DateTime.Now.ToString()));

    document.Add(new Paragraph("This is another test"));

    document.Add(new Paragraph("Yet another test"));

    }

    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 outputstream

    Response.OutputStream.Write(m.GetBuffer(), 0, m.GetBuffer().Length);

    Response.OutputStream.Flush();

    Response.OutputStream.Close();

    hi,everyone
    I want draw Bezier Lines for PDF with iTextsharp.

    But i did not konw how to do it.

    whether some friends konw that, pls tell me.

    my email:
         dlonghow@163.com

    or msn:
         dlonghow@hotmail.com


    Thank you everyone.