|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Prob: Dialog Box with pdf File
I am trying to link to a pdf file but I want the open/save dialog box to first appear. I have been able to get this code to work fine with other file types but for all pdf files, the file just opens in the browser. I have tried various combinations of cfcontent types, I don't know what else to try.
Below is a copy of my current code. <CFHEADER NAME="Content-Disposition" VALUE="attachment;filename=Trial.pdf"> <cfcontent type="unknown/unknown" file="c:\MyFolder\Trial.pdf" deletefile="no"> Please review the <a href="c:\MyFolder\Trial.pdf" target="_blank"> document </a> For testing I have a pdf file on my PC, however, the actual link will be to a pdf file on another website (in case that makes a difference.) Any advice would be greatly appreciated!!! |
|
#2
|
|||
|
|||
|
You may not be able to do this, as I'm pretty sure the acrobat reader plugin will automatically open the pdf in the browser and there's nothing you can do about it. I believe the only way to save a pdf is to right click and choose "save".
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Actually my bad, you may be able to do this but you can't put the cfcontent/cfheader link on the same page as the link to the pdf. What you really want to do is have a link that says something like
<a href="loadpdf.cfm?pdffile=mypdffilename.pdf">Review the File</a> And then on loadpdf.cfm, you'd do the cfcontent... <CFHEADER NAME="Content-Disposition" VALUE="attachment;filename=#url.pdffile#"> <cfcontent type="unknown/unknown" file="c:\MyFolder\#url.pdffile#" deletefile="no"> <cfabort> This type of thing can take a lot of messing around with to get to work, and even then different browsers may handle it in different ways... |
|
#4
|
|||
|
|||
|
AMAZING!!! Your suggestion worked - I am now able to get the save/open dialog box, however, another small issue. I am able to save the pdf file and then when I try to open it (or open it directly from the dialog box) I now get a message that says "This document contains no data". I confirmed that there is something in my pdf file that I am linking to and even tried linking to two different documents to verify the problem was not with the pdf file. Have you seen this issue?
Almost there.... |
|
#5
|
|||
|
|||
|
AMAZING!!! Your suggestion worked - I am now able to get the save/open dialog box, however, another small issue. I am able to save the pdf file and then when I try to open it (or open it directly from the dialog box) I now get a message that says "This document contains no data". I confirmed that there is something in my pdf file that I am linking to and even tried linking to two different documents to verify the problem was not with the pdf file.
It appears that by putting the pdf file name in one file and then calling the loadpdf.cfm file, it treats the pdf filename from the first file as if it were a new file/document with nothing it in. Have you seen this issue? Almost there.... |
|
#6
|
|||
|
|||
|
No, I haven't. You might have to play with it. Another option would be to offer 2 links next to the pdf, one that says "Download" and one that says "View". Then you could either do the download as you are doing now, or just open the pdf inline.
|
|
#7
|
|||
|
|||
|
There you go
You are not downloading the file in a proper manner. Observe the actual size of the downloaded file and you'll see is a few bytes.
The following works fine: <cfset yourFileName="whatever_name.whatever_extension"> <cfheader name="Content-Disposition" value="attachment;filename=#yourFileName#"> <cfcontent type="application/x-unknown" file="physical path to your file on the server\#yourFileName#"> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Prob: Dialog Box with pdf File |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|