Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
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 22-Jan-13 23:03pm
Edited 22-Jan-13 23:17pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

To force the web browser to display "Save As" option, you have to specify "application/octet-stream" Content-type.
  Permalink  

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

  Print Answers RSS
0 CPallini 550
1 Sergey Alexandrovich Kryukov 405
2 George Jonsson 288
3 Pheonyx 218
4 OriginalGriff 200
0 OriginalGriff 4,813
1 CPallini 3,890
2 Sergey Alexandrovich Kryukov 3,274
3 George Jonsson 2,552
4 Gihan Liyanage 2,186


Advertise | Privacy | Mobile
Web02 | 2.8.140905.1 | Last Updated 24 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100