Add New MIME Type to Open PDF Files Directly in Browser

Unable to open PDF/HTML/XML files directly in a browser in SharePoint 2010? The default configuration of SharePoint 2010 does not consider PDF documents safe for displaying in the browser. This script adds a new MIME type to the "AllowedInlineDownloadedMimeTypes" property list of the defined SharePoint.
Method 1

  1. Open the SharePoint Central Administration.


  2. Select "Application Management".
  3. Click on "Manage Web Applications".


  4. Select Particular Web Application .
  5. Got Ribbon and Select General Settings


  6. In the Browser File Handling section:


  7. Select "Permissive" and click "Ok".


  8. Clear the Browser Cache and open the PDF.


Method 2

Without changing the Web Application Settings (in other words Permissive and Strict).

This script adds a new MIME type to the "AllowedInlineDownloadedMimeTypes" property list of the defined SharePoint 2010 Web Application.
The script prompts you for the MIME type (for example application/pdf, text/html, text/xml) and Web Application URL.

The code shall run in the context of the Farm Administrators group member. 

# <#  


# This script adds new MIME type to "AllowedInlineDownloadedMimeTypes" property list of defined SharePoint 2010 Web Application. 

#  Script prompts you for MIME type and Web Application URL. 

#  Code shall run in context of Farm Administrators group member. 



If ( (Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null ) { 

    Add-PSSnapin "Microsoft.SharePoint.PowerShell" 




$WebApp = Get-SPWebApplication $(Read-Host "`nEnter Web Application URL"


Write-Host `n"Mime Type Examples:"`n"application/pdf, text/html, text/xml"`n 


If ($WebApp.AllowedInlineDownloadedMimeTypes -notcontains ($MimeType = Read-Host "Enter a required mime type")) 

  Write-Host -ForegroundColor White `n"Adding" $MimeType "MIME Type to defined Web Application"$WebApp.url 



  Write-Host -ForegroundColor Green `n"The" $MimeType "MIME type has been successfully added." 

} Else { 

  Write-Host -ForegroundColor Red `n"The" $MimeType "MIME type has already been added." 


Up Next
    Ebook Download
    View all
    View all