{"id":88,"date":"2011-10-05T20:34:52","date_gmt":"2011-10-05T14:34:52","guid":{"rendered":"http:\/\/markwheeler.com\/wordpress\/?p=88"},"modified":"2011-10-05T20:34:52","modified_gmt":"2011-10-05T14:34:52","slug":"displaying-pdfs-in-the-browser-from-sharepoint-2010","status":"publish","type":"post","link":"https:\/\/www.markwheeler.com\/?p=88","title":{"rendered":"Displaying PDFs in the browser from Sharepoint 2010"},"content":{"rendered":"<p>If you have a default SharePoint 2010 setup you would notice that when you go to open a PDF file SharePoint prompts you to save it rather than opening.<\/p>\n<p>The cause of this behavior is SharePoint 2010 Browser File Handling. This property is on SharePoint Web Application level and its value determines how files are treated in the browser. \u201cStrict\u201d specifies that MIME content types which are not listed in \u201cAllowedInlineDownloadedMimeTypes\u201d are forced to be downloaded. \u201cPermissive\u201d specifies that the HTML and other content types which might contain script are allowed to be displayed directly in the browser. <\/p>\n<p>\u201cAllowedInlineDownloadedMimeTypes\u201d is a collection of MIME types. This list of MIME types does not contain MIME type of Pdf documents by default. It is important to understand that by adding Pdf MIME type to IIS settings you will not solve this issue.<\/p>\n<p>Solution Part 1:<br \/>\nThe solution is to change Browser File Handling property on Web Application level. For that you need to be a Farm Administrator. Steps to change Browser File Handling property:<br \/>\nGo to SharePoint 2010 Central Administration > Application Management > Manage Web Applications<br \/>\nSelect the row of your web application<br \/>\nClick General Settings in the ribbon<br \/>\nScroll down to Browser File Handling and select Permissive<br \/>\nClick Ok<\/p>\n<p>Solution Part 2:<br \/>\nYou may still get prompted to open PDFs with the Client Application. Adding the MIME type will allow you to open the PDF in the browser.<br \/>\nHere is a Powershell script to affect this.<\/p>\n<p>$mimetypes = &#8220;application\/pdf&#8221;,<br \/>\n$webApp = Get-SPWebApplication http:\/\/portal<\/p>\n<p>foreach($mime in $mimetypes)<br \/>\n{<br \/>\n  If ($webApp.AllowedInlineDownloadedMimeTypes -notcontains $mime)<br \/>\n  {<br \/>\n    Write-Host -ForegroundColor White &#8220;Adding MIME Type &#8220;$mime<br \/>\n    $webApp.AllowedInlineDownloadedMimeTypes.Add($mime)<br \/>\n    $webApp.Update()<br \/>\n    Write-Host -ForegroundColor Green &#8220;MIME Type added and saved.&#8221;<br \/>\n   }<br \/>\n  Else<br \/>\n  {<br \/>\n    Write-Host -ForegroundColor Yellow $mime&#8221; MIME type is already added.&#8221;<br \/>\n   }<br \/>\n}<br \/>\nAfter executing this script, you have to restart your IIS in order this setting to get active: iisreset \/noforce.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have a default SharePoint 2010 setup you would notice that when you go to open a PDF file SharePoint prompts you to save it rather than opening. The cause of this behavior is SharePoint 2010 Browser File Handling. This property is on SharePoint Web Application level and its [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2,10,11],"tags":[18,76,98],"class_list":["post-88","post","type-post","status-publish","format-standard","hentry","category-computer","category-sharepoint","category-software","tag-18","tag-pdf-display-in-browser","tag-sharepoint"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/88","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=88"}],"version-history":[{"count":0,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/88\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=88"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=88"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=88"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}