1
votes

My program generates PDF in Browser (open the PDF in the browser). But when I want save the file in computer, the default name of PDF is always the same (the name of my class). I want to pass the name for different pdf's... This is my code:

protected void displayPDF(string filePath, string filename)
{
    Response.Clear();
    Response.ContentType = "Application/PDF";
    //what i do with filename?
    Response.WriteFile(filePath);
    Response.Flush();
    Response.End();
}

I tried this:

Response.AddHeader("Content-Disposition", "attachment; filename=myfile.pdf");

But this way, pdf doesn't open in browser, pass like an attachment.

Can you help me? Thanks.

1

1 Answers