1

I have referred the below link to make the pdf open in browser instead of downloading Configuring Sitecore to display PDFs in browser

The pdfs are still getting downloaded

I have done the below config changes, made the forcedownload option as false

Sitecore.config

<mediaType name="PDF file" extensions="pdf">
        <mimeType>application/pdf</mimeType>
        <forceDownload>false</forceDownload>
        <sharedTemplate>system/media/unversioned/pdf</sharedTemplate>
        <versionedTemplate>system/media/versioned/pdf</versionedTemplate>
      </mediaType>

MimeTypes.config

uncommented the below line

<mediaType extensions="pdf"><mimeType>application/pdf</mimeType></mediaType>

pdfs are still getting downloaded in chrome instead of opening in a new tab. In IE it opens in a tab. Have also verified the setting in chrome for pdf download to be disabled. Is there anything else missing ?

  • Could you please check showconfig.aspx once and verify the changes are reflecting. Just to make sure no cache issue. – Gobinath Saminathan Nov 7 '19 at 14:15
  • Could you also check "developer tools" in Chrome to see which response headers are sent when you request a PDF file? – GTHvidsten Nov 7 '19 at 14:30
  • Is it a SXA site , custom pipeline ?forcedownload , this info also may be reqd – Abhay Dhar Nov 7 '19 at 16:56
  • @AbhayDhar yes it is a SXA site, no custom pipeline is written. – user3267206 Nov 11 '19 at 6:38
2

I am using the below patch configuration file for Sitecore 9.1 (Initial Release) and SXA 1.8 to stop the download of PDF files. It works fine for me

<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <!-- Force download of PDF files -->
    <mediaLibrary>
      <mediaTypes>
        <mediaType name="PDF file" extensions="pdf">
          <forceDownload>false</forceDownload>
        </mediaType>
      </mediaTypes>
    </mediaLibrary>
  </sitecore>
</configuration>
| improve this answer | |
  • Its worked for me after clearing the cache on sitecore server through admin/cache.aspx. My application is hosted on azure paas and CM n CD servers are different. Its working fine on CM after clearing cache, but not on CD as i dont have a option to clear cache. Any idea ? – user3267206 Nov 11 '19 at 10:23
  • try restarting the app services of CD – Abhay Dhar Nov 11 '19 at 10:37
  • Thank you !! its working now – user3267206 Nov 13 '19 at 9:26
  • Google Chrome on Windows was a bit persistent. I had to clear the browser cache and close and re-open the browser to get this fix to be recognized. – Neil Monroe Dec 27 '19 at 0:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.