• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

How to convert the Page into PDF in ASP.Net

Hi Experts,
      How to Convert the Page into PDF in ASP.Net. I have used the following Code to convert the page into PDF but i'm getting an error as invalid pdf format.

The Code is As follows :

    Response.ContentType = "application/vnd.pdf";      
    Response.AddHeader("Content-Disposition","attachment; filename=test.pdf");

Suggest me how to convert the page content type to PDF or give me some sample code which would help me in solving this problem


1 Solution
There is no easy way to convert page into PDF.
When you change the ContentType property of Response object, then you must provide output in the correct binary format.
To do what you want to achive you would have to override Render method and do not render any html tags, but only binary content.
Unfortunetely there is no automatic mechanism that will do the convertion for you.

also take a look at this project: http://sourceforge.net/projects/itextsharp/

i found this page: http://www.aspnetworld.com/articles/2004011801.aspx there is a list of several open source and commercial PDF generating libraries for you to use.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now