-
PDF Download link
Hi,
I want to create a simple link (pdf image and text) from which the user can simply download a pdf document.
I store the whole link html string in a resource file, as it depends on what language the user are using.
Seems that if you say a href ='mydoc.pdf', then the document are opened in the same page, just a bunch of garbage....
I want the dialog to come up...normal way
-
Re: PDF Download link
what happens if you use href='file:\\path\mydoc.pdf' ?
-
Re: PDF Download link
Code:
<a href='file:\\CASM_sample_en.pdf'>test</a>
say page cannot be found.
Code:
<a href='CASM_sample_en.pdf'>test</a>
open the file in the same window, but not pdf, just garbage (I assume IE read into the file)
-
Re: PDF Download link
I think your browser just isnt set up right, try downloading a pdf from another site.
-
Re: PDF Download link
Thanks for the advice.
However, I have to make sure anyone, using any browser, will be able to download this documents (sample issues, subscribtion forms, etc) from my website.
I did got across some code the other day, but did not look into it...will look into it later, as I got myself caught up in some stored procedures right now.
thanks again!
-
Re: PDF Download link
If you upload the pdf file to a location on your site you will reference it just like any other page. If they have Acrobat then it will open in the browser. If they dont then it will present the save to dialog so they can download the file.
For ex: http://www.vbforums/downloads/myfile.pdf
-
Re: PDF Download link
that's what I thought too...believe me, it dont
-
Re: PDF Download link
Hmm, I havent linked to a pdf in a while but thats how I have always done it with Acrobat 5 and 6.
-
Re: PDF Download link
BTW, it's file:///, not file:\\.
-
Re: PDF Download link
yeah...me too long ago when i played around with html, before going to good ol vb6.
apparantly one have to do something like this. I will post the solution once I got to that (got busy with some other stuff...how's that for holiday?)
Code:
Private Sub Page_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Response.ContentType = "application\octet-stream"
Dim filename as string=new string("c:\\downloads\\hi.doc")
Dim downloadFile As System.IO.FileStream = New System.IO.FileStream(filename, IO.FileMode.Open)
Response.Write(downloadFile.Length() & "#")
downloadFile.Close()
Response.WriteFile(filename)
Response.Flush()
Response.End()
End Sub
-
Re: PDF Download link
Yes that is the right way, except that the content type is usually "application\pdf"
-
Re: PDF Download link
application/pdf will open it in the browserwindow. application/octet-stream should trigget a download.
-
Re: PDF Download link
uuuurgh..no luck
Code:
//Set the appropriate ContentType.
Response.ContentType = "application/octet-stream ";
//Get the physical path to the file.
string FilePath = MapPath("../downloads/CAND_Subscribe_en.pdf");
//Write the file directly to the HTTP content output stream.
Response.WriteFile(FilePath);
Response.End();
Response.Flush();
Response.End();
-
Re: PDF Download link
Try the following link:
File Upload/Download
Hope this helps!
Gary