Link to home
Start Free TrialLog in
Avatar of coerrace
coerrace

asked on

Save PDF and avoid the browser open

hello we have a windows server 2008 and we want the users download the PDF files when they click instead of open in the browser with acrobat reader. Is like a force to save and automatic downloading.
  If you have examples of code we use ASP, javascript preference. We don't use PHP.
Thank you
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of coerrace
coerrace

ASKER

Could yoy tell me how to use or call in an HTML or asp page. Want to know how to apply or how to ise this code.
Thank you
Do you already have the pdf files created? Maybe you can post your code that you use to lay your pdf files and I can help you modify it
You have to add some header info.   If you saw something in php, this is probably the similar solution in asp.   http:Q_21929242.html#a17166603
Big Monty this is what I have in code is a file in .html:
<SCRIPT>
function download()
{
      
window.open('file2.asp');
}
</SCRIPT>
    <SPAN onmouseup='javascript:download()'; style='cursor:pointer;display:inline-block;white-space:nowrap;'><SPAN><TABLE onmouseover='this.className="buttonback1o"' onmouseout='this.className="buttonback1"'; class='buttonback1' cellspacing=0 cellpadding=0 height=100%;'><TH align=center valign=middle><SPAN style='white-space:nowrap;'><P class=buttontext>Download PDF</TH></TABLE></CENTER></SPAN></SPAN>

file2.asp is your code if you click mouse sends you to the page and display the content like text and not execute the VB code if I run the file.asp like http://xxx.xxx.xxx.xxx/file2.asp workks perfect download the file but we can't make http syntax we need to call in the same directory the .html it is we can't use http.
Thank you
As a starting point, put the code I posted in its own file (displayPdf.asp) , and on the page that lists out the files, have them link to that page, along with the path listed in the query string so it would look like

<a href ="displayPdf. asp? path=/PathToFile/filename.pdf">pdf name display</a>

Open in new window


Then on line 2, change it to

  FPath = server.mappath(Request. QueryString("path") ) 
  

Open in new window

Just saw your post, have a) at mine and see if it works for you. Let me know if you have any additional questions
Worked perfect running the html from www http and your code in same dir.
Thank you