1

I've a document library in SharePoint 2010 with some pdf. When i click on a pdf, it proposes save as in place of open.

How to achieve this?

I added this in my master page:

 $(function () {
    $("a[href$='.pdf']").removeAttr("onclick");
    $("a[href$='.pdf']").removeAttr("onmousedown");
    $("a[href$='.pdf']").attr("target", "_blank");       
});

Thanks

-1

You have to make sure the following things in order to open the PDF in browser.

There are two options available

  • Browser File Handling should permissive for the web app, you can change it using the Central Admin > Manage web Application> Web Application General Settings. this is kind of security risk.
  • Explicitly add PDF to allowable list of MIME types in SharePoint 2010. .Use the below code to add MIME type

    -#Get web application object   
    $webApp = Get-SPWebApplication "web app url"   
    -#List all allowed MIME types for this web application
    $webApp.AllowedInlineDownloadedMimeTypes  
    -#Get web application object again
    $webapp = Get-SPWebApplication "web app url"  
    -#Add PDF to allowed MIME type list    
    $webapp.AllowedInlineDownloadedMimeTypes.Add("application/pdf")
    -#Commit changes
    $webapp.Update()
    

http://mssharepointtips.com/tip.asp?id=1187

Also Take a look:

How to Open PDF files in a web browser -SharePoint 2010

  • If you are using Adobe Acrobat, you will need at least version X of the software. Also, check if your Acrobat to browser integration is working. – Arsalan Shahid May 20 '15 at 21:02
  • I would definitely not recommend setting it to permissive in production and instead intentional declare it's use (Waqas 2nd bullet). and as far as opening in the browser itself - that will also depend on the browser and/or application plugins being enabled. – Jesus Shelby May 20 '15 at 21:08
  • Are there a way to open pdf in new tab browser? – user1898765 May 21 '15 at 10:00
  • you need to add a CEWP and put a code it..check this synergyonline.com/Blog/Lists/Posts/Post.aspx?ID=18 – Waqas Sarwar MVP May 21 '15 at 13:44
  • i put the code in master page, like this every pdf on every library are open in a new tab – user1898765 May 25 '15 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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