473,322 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

how to show pdf file on aspx page without save option?

I m putting link to pdf file , on click which should open in same or other page and that pdf file should be visible on the page, how to do this,

on givin link of pdf file it's directly showing download dialouge ...
Jun 18 '12 #1

✓ answered by Frinavale

If the user has a plugin installed in their browser, the PDF file will be displayed in the browser. Otherwise, the user will be prompted to download the PDF file so that they can choose a program installed on their computer that can open the file.

If you want to display the PDF in another page, simply set the target of the hyperlink to "_blank"...like this:
Expand|Select|Wrap|Line Numbers
  1. <a href="urlToPDF" target="_blank">PDF</a>
If you're using an ASP.NET HyperLink control, your code would look like:
Expand|Select|Wrap|Line Numbers
  1. <asp:HyperLink id="hyperlink1" 
  2.                NavigateUrl="urlToPDF"
  3.                Text="PDF"
  4.                Target="_blank"
  5.                runat="server"/> 
If you want it to be displayed within the same page, then you don't need to specify a target. This will replace the content being displayed in the browser with the PDF document.

If you want the PDF document to be displayed within the content of your page, then consider using an <iframe /> to do so.

-Frinny

5 12187
Frinavale
9,735 Expert Mod 8TB
If the user has a plugin installed in their browser, the PDF file will be displayed in the browser. Otherwise, the user will be prompted to download the PDF file so that they can choose a program installed on their computer that can open the file.

If you want to display the PDF in another page, simply set the target of the hyperlink to "_blank"...like this:
Expand|Select|Wrap|Line Numbers
  1. <a href="urlToPDF" target="_blank">PDF</a>
If you're using an ASP.NET HyperLink control, your code would look like:
Expand|Select|Wrap|Line Numbers
  1. <asp:HyperLink id="hyperlink1" 
  2.                NavigateUrl="urlToPDF"
  3.                Text="PDF"
  4.                Target="_blank"
  5.                runat="server"/> 
If you want it to be displayed within the same page, then you don't need to specify a target. This will replace the content being displayed in the browser with the PDF document.

If you want the PDF document to be displayed within the content of your page, then consider using an <iframe /> to do so.

-Frinny
Jun 18 '12 #2
PsychoCoder
465 Expert Mod 256MB
Here's an option that should work for what you're trying to do:

Expand|Select|Wrap|Line Numbers
  1. private void ReadPdfFile()
  2. {
  3.     var pdfPath = @"C:\YourPDFFile.pdf";
  4.     var client = new WebClient();
  5.     var buffer = client.DownloadData(pdfPath);
  6.  
  7.     if (buffer == null) 
  8.         return;
  9.  
  10.     Response.ContentType = "application/pdf";
  11.     Response.AddHeader("content-length", buffer.Length.ToString());
  12.     Response.BinaryWrite(buffer);
  13. }
Hope that helps
Jun 19 '12 #3
if you use System.Diagnostics.Process.Start(FilePath) then that file will be opend automatically......i think this will solve ur problem..
Jun 19 '12 #4
Frinavale
9,735 Expert Mod 8TB
How is System.Diagnostics.Process.Start(FilePath) supposed to open the file in the browser?

When a web browser downloads content it has to determine what to do with that content. If the content is HTML, then it displays the HTML webpage. If the content is a PDF document, it checks to see if it has a plugin installed that can open and display this content...and if there is no plugin installed that can handle the content that it's downloaded, it asks the user what to do with it (save it and open the document with a program that knows what to do with it).

-Frinny
Jun 19 '12 #5
Dear it is promting dialoge to download the file I cant let pdf to view in browser thru this..
Jun 28 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Fabrizio | last post by:
HI, i'm creating an ASPX page without code behind, including some C# script. Trying to create a Dataset it gives me the error that probably is missing a "using" or a reference to a dll. How can...
1
by: Jerry Tovar | last post by:
I am using .Net 2003 on a XPPro running IIS. I am unable to view any of my ASPX webforms in a browser unless I modify the .ASPX file and replace Codebehind="employee.aspx.cs" with...
2
by: vn | last post by:
I have deployed a simple aspx application on my server(which has windows2003 & iis6.0) and also deployed on my workstation(windows 2000workstation & iis5.0) Application runs fine when tested...
9
by: Steve Peterson | last post by:
Hi I have an .aspx web form in which I would like to output only XML, no HTML. The datasource is a datatable that's bult on the fly based on user input from previous .aspx page so the XML output...
2
by: Gerald | last post by:
Hi, can anyone please solve this problem? My main page is :WebForm2.aspx <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm2.aspx.vb" Inherits="Transactions.WebForm2"%> <%@...
2
by: Ravi | last post by:
Hi, I am trying to call an aspx page from an htm file. I have written something like this in my htm file <script src="Test.aspx"></script? The Test.aspx page should call a javascript function...
2
by: paul.gibson | last post by:
I have a released web app where I have found a bug that can be fixed simply by moving a JavaScript <scriptblock from the bottom of an ASPX page to the top. Is it a safe/accepted practice to...
2
by: maralikatti | last post by:
Hi All, I have a .aspx page, through which I want to download a file from web-server to client machine's known path, without user intervention (download dialog should not appear). Can anybody...
1
by: raven0522 | last post by:
hi, i want to print a div section in my aspx page without having to use a popup. Right now I am just calling a javascript function and passing the Div ID to it on the Print button click event. ...
0
by: Alain Quesnel | last post by:
Hi, I'm trying to do something fairly simple. I want to create a web page that will take a parameter in the URL and return a file on page load. The file is stored in a MSSQL 2005 database in an...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.