What Is Wrong With My Export Code

  • What iis wrong with the following code?

    Response.Clear();

    Response.ClearHeaders();

    Response.ClearContent();

    Response.AddHeader("Content-disposition", "attachment; filename=TestDeviceFilter.pdf");

    Response.ContentType = "application/pdf";

    Response.Buffer = true;

    StringWriter stringWriter = new StringWriter();

    HtmlTextWriter htmlTextWriter = new HtmlTextWriter(stringWriter);

    //this.RenderControl(htmlTextWriter); this is for whole page.

    RV_Reports.RenderControl(htmlTextWriter);

    Response.Write(stringWriter.ToString());

    Response.End();

    I get the following when I try to open the PDF:

    Adobe Reader could not open 'myfile.pdf' because it is either not a supported file type or because the file has been damaged

  • Microsoft does not sell PDF dll so you need third party PDF dll in your application to render PDF through the response object. Check below for two but I have not used both.

    http://sourceforge.net/projects/pdfsharp/?abmode=1

    http://itextsharp.sourceforge.net/

    Kind regards,
    Gift Peddie

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply