Is it Possible to download a pdf file from a web page without showing the URL of pdf file in address bar
-
Hi, I am working on a website and on the home page we have a pdf file link. The moment user clicks on that link the control takes the user to new URL, also displays the URL in the Address line of Browser, where the PDF file exists. However I don't want to show this URL to user, so that he can't copy and paste that URL in another browser. Is there any way possible to hide such details or is it possible to just download the pdf without showing the URL (one where PDF file actually exists) in the address line of the browser. If user is able to download also it is fine. The only thing we need is to hide the URL. Thanks in Advance!!
-
Hi, I am working on a website and on the home page we have a pdf file link. The moment user clicks on that link the control takes the user to new URL, also displays the URL in the Address line of Browser, where the PDF file exists. However I don't want to show this URL to user, so that he can't copy and paste that URL in another browser. Is there any way possible to hide such details or is it possible to just download the pdf without showing the URL (one where PDF file actually exists) in the address line of the browser. If user is able to download also it is fine. The only thing we need is to hide the URL. Thanks in Advance!!
you can zip that pdf then user download it wirhout opening in another browser
Gaurav Dudeja http://www.gdinfotechindia.com
Dont be afraid of changing your life to better ! -
Hi, I am working on a website and on the home page we have a pdf file link. The moment user clicks on that link the control takes the user to new URL, also displays the URL in the Address line of Browser, where the PDF file exists. However I don't want to show this URL to user, so that he can't copy and paste that URL in another browser. Is there any way possible to hide such details or is it possible to just download the pdf without showing the URL (one where PDF file actually exists) in the address line of the browser. If user is able to download also it is fine. The only thing we need is to hide the URL. Thanks in Advance!!
If you are using ASP.NET you can create an aspx site where you check if the user has the right to download/see the pdf (maybe through a temp guid). If he has the right, then you can send this pdf through the response stream to the client pc. Example: .aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GetPDF.aspx.cs" Inherits="[namespace].GetPDF" %>
.cs
public partial class GetPDF : System.Web.UI.Page { protected void Page\_Load(object sender, EventArgs e) { try { // check access rights or guid Response.Clear(); // read pdf (hosted on server site) trough binary stream to a byte array buffer Response.ContentType = "application/pdf"; Response.BufferOutput = true; Response.Cache.SetNoServerCaching(); Response.Cache.SetNoStore(); Response.OutputStream.Write(buffer, 0, buffer.Length); } catch (Exception) { } } }
Maybe the user sees the url "http://.../GetPDF.aspx?querystring" but through your check, copy and paste the url will not work. (You could create a temp guid to access the pdf for the user, provide it in the querystring and delete this temp guid after downloading. On the next call of this url the user will not be able to download it again.) Hope this helps. Edit: In addition to the example above, you can also use the session object to check if the user has the rights to access the pdf file. Just set a session value (like
Session["UserCanAccessPDF"] = true;
) on link click event and check this session value on GetPDF::Page_Load. If the session value is invalid or not set, just redirect to an error page (or something else). If the value is valid, send the pdf trough the stream and delete the session value.Greetings Covean
modified on Thursday, April 29, 2010 7:01 AM
-
you can zip that pdf then user download it wirhout opening in another browser
Gaurav Dudeja http://www.gdinfotechindia.com
Dont be afraid of changing your life to better !You can use the Content-Disposition HTTP header to force the file to download and not open in the browser. No zipping required.
-
Hi, I am working on a website and on the home page we have a pdf file link. The moment user clicks on that link the control takes the user to new URL, also displays the URL in the Address line of Browser, where the PDF file exists. However I don't want to show this URL to user, so that he can't copy and paste that URL in another browser. Is there any way possible to hide such details or is it possible to just download the pdf without showing the URL (one where PDF file actually exists) in the address line of the browser. If user is able to download also it is fine. The only thing we need is to hide the URL. Thanks in Advance!!
Assuming ASP.Net... Create a button. In the click handler, write the file to the HTTP response, as the previous poster suggested. That way, you aren't using a different URL. The only way they can get the file would be to click the button. You can have whatever logic you like to decide when to display that button, or if they manage to click the button when they are not allowed, you can add additional validation to prevent the download. You could, for example, validate that the user has never downloaded the PDF before so that they can't download it a second time. If they have already downloaded it, you could show a message that says "sorry, but you are only allowed to download this PDF once". The PDF data you return can come from the server file system or from a database on the server (or even from another server). Where you want to get the PDF from is up to you.
-
Assuming ASP.Net... Create a button. In the click handler, write the file to the HTTP response, as the previous poster suggested. That way, you aren't using a different URL. The only way they can get the file would be to click the button. You can have whatever logic you like to decide when to display that button, or if they manage to click the button when they are not allowed, you can add additional validation to prevent the download. You could, for example, validate that the user has never downloaded the PDF before so that they can't download it a second time. If they have already downloaded it, you could show a message that says "sorry, but you are only allowed to download this PDF once". The PDF data you return can come from the server file system or from a database on the server (or even from another server). Where you want to get the PDF from is up to you.
Perhaps you can use Server.Transfer("url");[^] instead of Response.Redirect("url");..... good luck ;) ;)
-
Perhaps you can use Server.Transfer("url");[^] instead of Response.Redirect("url");..... good luck ;) ;)
Not sure that's what the OP is after, but perhaps you should redirect your answer to the OP anyway. It's certainly going to do me no good. :rolleyes:
-
Hi, I am working on a website and on the home page we have a pdf file link. The moment user clicks on that link the control takes the user to new URL, also displays the URL in the Address line of Browser, where the PDF file exists. However I don't want to show this URL to user, so that he can't copy and paste that URL in another browser. Is there any way possible to hide such details or is it possible to just download the pdf without showing the URL (one where PDF file actually exists) in the address line of the browser. If user is able to download also it is fine. The only thing we need is to hide the URL. Thanks in Advance!!
ups... sorry aspdotnetdev! ok! my answer was:............... Perhaps you can use Server.Transfer("url");[^] instead of Response.Redirect("url");..... good luck ;) ;)