Click here to Skip to main content
16,018,264 members
Please Sign up or sign in to vote.
1.30/5 (3 votes)
See more:
i have to display pdf file in aspx page.
->when i click on view button pdf file will be display
when i click on download button ,pdf file will be downloaded.
what i have to do for this.
Posted
Updated 21-Mar-17 23:56pm
v2

Hi,

If a specific browser supports PDF (like Chrome does) it can be configured by default to display the file instead of downloading it.

otherwise the response is HTML so you can't just do that, either you create html to display or try a different approach (than showing the pdf file in the browser)

Cheers,
Edo
 
Share this answer
 
v2
can't just do that,

An alternate is zip that pdf via code for download link. there are lot of methods on wen to zip you pdf file.
 
Share this answer
 
To force the web browser to display "Save As" option, you have to specify "application/octet-stream" Content-type.
 
Share this answer
 
C#
Response.ContentType = "Application/pdf";
Response.TransmitFile(pathtofile);

If you want the PDF to open in a new window you would have to open the downloading page in a new window, for example like this:

<a href="viewpdf.aspx" target="_blank">View PDF</a>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900