• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 426
  • 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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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