There are two ways on our sitecore website we are associating an item (article) with a related media PDF item:
- One way is by clicking the "Insert Sitecore Link" button in the RichTextEditor of a content value field of that content item, which produces something like:
< a href="~/media/EB5BA6C0CCCF4781B668DE863EE996D9.ashx">emad_pdf_test_1< /a >
< a href="~/media/1978B759E83348CFB23870AE31494765.ashx">emad_pdf_test_2< /a >
- The second way is by choosing the related media PDF item by selecting it via a PDF field (which has the 'open file', 'download', 'view file', and 'clear' options). That produces something like:
< a ... href="/DownloadMedia.aspx?media={EB5BA6C0-CCCF-4781-B668-DE863EE996D9}" >Download PDF< /a>
The first way (#1) has caused some people to have download issues in IE8 & IE9. Anyway, after some excruciating trial and error, we have decided we want to change all the places where we render like #1 (.ashx) to instead render like #2 ( DownloadMedia.aspx?media={GUID} ). We know for a fact all PDF downloads in all browsers would work if we did this.
We realize one repercussion of this is that if we physically delete a related PDF media item in sitecore, sitecore will not warn us of broken links if in RichTextEditor, that PDF media item was referenced in the DownloadMedia.aspx?media={GUID} format. Is there any way around that problem?
Also are there any other repercussions for us changing the rendering of PDF from ".ashx" to "DownloadMedia.aspx"?
You can update the default web.config to force download of PDF files when linking via standard Sitecore links (and media handler). This would mean you would not need to change any of the ways you link when using #1
The issue with PDF in certain versions of IE is a known issue and Sitecore 7.2 now changes the
forceDownload
to betrue
by default.Release History for Sitecore CMS 7.2
EDIT:
It seems the issue is related to chunked transfer encoding and IE9/Acrobat Reader plugin not playing nicely together. You can read more information here but the fix is to disable chunked transfer encoding for media items in config:
The original answer is still the best option for the OP's question, i.e. how to force the browser to download PDF files, but this resolves the specific issue as to why he was having issues with IE8/9 browsers.
You can extend the media handler instead to keep using the sitecore links and force the download.
http://sitecoreblog.alexshyba.com/2010/07/file-download-dialog-box-for-sitecore.html?m=1