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 ?

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

1 Answer 1

3

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>
6
  • 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 ? Nov 11, 2019 at 10:23
  • try restarting the app services of CD
    – Abhay Dhar
    Nov 11, 2019 at 10:37
  • Thank you !! its working now Nov 13, 2019 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. Dec 27, 2019 at 0:47
  • @AbhayDhar This is working like a charm. if multiple websites are in single sitecore instance and this has to be applied to a specific website. I made these changes to this patch config and its not working. May 10, 2021 at 8:21

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