unable to create a pdf from html file using itextsharp with asp.net

.net , asp.net Thrissūr, India
  • 12 years ago
    private void Button1_Click(object sender, System.EventArgs e)


    Document doc=
    new Document(PageSize.A4);System.IO.MemoryStream FStream = new MemoryStream();






    new FileStream("DiplomaTest.pdf",FileMode.Create));








    catch(Exception ex)


    throw ex;







    giving the error---------document has no pages and opening the pdf with a message saying that file has corrupted.

    I am trying a lot on this from so many days.

    Please help me.


    With Regards,


  • 12 years ago

    HtmlParser.Parse does NOT throw any error , but the pdf file generated from this could be blank/empty.

    Debug output shows the messages from parser, if Html file has invalid structure.

    The post of Creating pdf in .NET from html has a lot of interesting comments,

    including suggestion  to use HTML Agility Pack.


Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The difference between theory and practice is smaller in theory than in practice.”