How to convert the Page into PDF in ASP.Net

Posted on 2006-05-01
Last Modified: 2008-02-01
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


Question by:mohan21_kumar
    LVL 6

    Accepted 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:

    Expert Comment


    i found this page: there is a list of several open source and commercial PDF generating libraries for you to use.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    Title # Comments Views Activity
    string initialization in java 11 94
    array6 challenfge 6 48
    wordmultiple challenge 12 62
    java  and programming certification ? 4 27
    A short article about problems I had with the new location API and permissions in Marshmallow
    If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
    In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now