No one has responded to this discussion for at least a year, so this information may be out of date. If you're looking for information about this topic, please search for a more recent discussion or post a new question.

PDF Solution: Here's How to Display in the Browser

  • This post has 176 Replies |
  • Nice work....opens fine in Firefox but ironically, it doesn't open for me in IE9 :-)

  • Thanks Steve.  I'm on IE8 so thanks for reminding me to turn off auto updates and prevent upgrade to IE9!

    Does Adobe reader open PDFs from other sites in IE9 for you?

  • Yeah I can open PDFs from other sites ok.... when i try yours, I get the a white page and a little red 'X' in the top left corner. I'm on 64 bit IE9 which won't even open Flash so be to do with that maybe.

  • Steve, Don't know if this will help w IE9 but you could try this:

  • Yeah it's a x64 thing:

    try 32 bit IE9



  • Would this work if I had a private site with a document library full of pdf documents?

  • Bernie, yes it would.  In fact even my page will open your pdf as long as you're logged into your private site.

    Try typing the full path to your file like this:

  • I'm missing something.  How do I get this to work for my clients who will be opening pdf files in a library that I would create for them.

  • The process is fairly straight forward, but I havn't had time to make it an installable sharepoint solution.


    All you have to do to get it to work is:

    Save pdf.aspx in the doc library


    To make it more useful for your clients you have to provide a link in the library like this:

    add a column to the doc lib called something like DocURL.

    add a workflow which sets the value of that column to the URL of pdf.aspx with the respective pdf file in the query string like this:

    Show that column instead of the built in 'Name (with link)' column in the Doc Lib View


    I've developed and proven the workflow, but havn't made this into a uploadable solution yet.  Sorry.



    Here is a complete installable solution with instructions:



    0 out of 1 people found this post helpful.

  • Hi Jbooker

    This is realy nice work from you - Respect on scripting and research :-)

    But we need a central solution from MS on this.

    PDF files are normal all around the world - and I love the MS products.

    But fore the first time in my life I'm wondering...Is this because MS want to force their own formats?


  • Hi Stein,

    Thanks.  You're right i don't want to take the heat off MS to provide a built-in fix.  We need a secure PDF viewer like the silverlight XPS\PDF viewer they already have on

    Not only does the above solution provide a method that some may find useful also proves that browser file handling set to strict is not so strict.  Perhaps MS will turn up the heat and provide a secure viewer very soon.



  • Hi Josh,

    It's definitely a nice work around for non-IE browsers.

  • Thank you Eric.  BTW, It works fine in IE 32-bit as well.

  • very nice indeed .. anyway you could have a workaround for viewing html files in your browser as well?

    urgently need to be able to show html files!

    thanks in advance

  • very nice post .. I actually need this urgently for viewing html files, could this be done for html also?

  • Chris,

    The exact method of embedding didn't work for HTML in my first try, but I am confident a variation of this would work for HTML files.  Sorry I can't work that out with any urgency, but if you're crafty you could take what I've done and work with it to find the solution.  I will post back here when I do get to working through the html solution.


  • Did you have anything else that you wanted to add to this thread jbooker?

  • Mike,

    Thanks for asking.  Yes I do as will others who may have questions about this solution.  This is an open discussion about the PDF work around presented in the beginningn of this thread which I hope will remain open.

    Thanks again,


  • Joshua - how nice of you to offer this!  I was able to check it out using your sample link above.  However, when I replaced the file name with one of ours, I got this message:

      File does not begin with '%PDF-'.

    Is there a special file naming syntax you are expecting?


  • oh - update - I had tried it in IE 9.  I just now tried in Safari 5.0 and it worked just fine!  Maybe back to the 64-bit thing?

  • Betty,

    You will get that message if you are opening a pdf file from a private site while not logged into that site.

    It may be the same message for x64 IE I'm not sure.  Try again in IE9 while logged into your private site and see if it works.

    Stay tuned as I have an installable solution to get this working on your own site forthcoming.


  • Chris,

    I've tried and don't have a way that works for HTML files.  So far the only option is to save your html with .aspx extensions then they will work.

    Don't know if that will help, but it's all I know of.


  • Josh - Just to let you know, I verified that I was logged into my site before linking, and still got the same error.  I had someone try it on their IE8 browser and they said it worked just fine though.  And cool news that you're working on an installable solution!   Happily staying tuned .......     8-)

  • Betty,

    Thanks for the info.

    You could try this:

    I havn't tried with IE9 so I'm not sure it will help, but may be worth a try.

    You could also try a smaller PDF file or refresh the page after the error message as it may be that the adobe plug-in isn't waiting for the file to cache fully.



  • late getting back to you, but yea, the same thing happened when I tried your test file from IE9.  I get the "File does not begin with '%PDF-'. message....

  • Ian Morrish also has a suggestion ...

    Displaying PDF files in Office 365 SharePoint Online sites

    Ian's SharePoint Blog

  • Betty,


    I saw Ian Morrish's blog last week.  He's doing the same thing by using javascript to embed the PDF object.  I like his method of getting the PDF file URL directly from the form.  As he says, there are many way s to do this.  His example works great if you want to display the PDF on the same page as one of the sharepoint forms.  If you want to show the PDF in full screen like most people may expect, then you have to rework his code a bit.


    Here is my solution that you can dowload and install on your private site:



    Let me know if you have questions.


  • I'll spread the word about your solution - so good and generous of you to go through the trouble to provide this!  I'm sure you are making a lot of people happy!

  • I implemented this solution as directed in your link but it does not work for me. I still get the "Save ro Cancel" dialog box.

    I believe I may not have access to the javascript "sp.js" that you've embeded in the <HEAD> section of the page. Where is the /utilities directory located where this script is supposed to reside?

    Furthermore, the getDoc() procedure does not contain a parameter to indicate which document it's supposed to get.

    Can you provide further clarification?

  • OK, I figured it out. I have to use YOUR website,, to get this to work instead of MY website, http://<mywebsite>/Documents/pdf.aspx?file=http://<mywebsite>/Documents/<myfile>.pdf.

    I was hoping to be able to implement this on my site because, no offense, I'd rather have the address bar of the browser window in which the PDF opens to reflect MY website, rather than yours. It may tend to confuse my viewers.

    And again, I believe it's because I do not have access to your sp.js script. I guess I could reverse engineer it since I now believe I know how it works.

  • Howard,

    Not sure I get what you mean. I tested this with Josh a while back and it installs on your account and opens a document stored in your account with your address in the address window.

    Click "pdf test" on this page:

    Josh outlines the different approaches to public/private sites in his article. 

    Can you post an example?   |     |  Get more out of Office 365

  • Hi Howard,

    You should be able to open files on your own site.  The Site template includes the utilities document library which contains pdf.aspx and sp.js.  Everything is on your site.

    Do you see the utilities library when under 'all site content'?

    Did you upload a PDF file to the Documents Library of the new site?  What happens when you click on PDFLink?


  • Howard,


    Try this:




    pdf.aspx is in the utilities doc lib.





  • Nice Post .... Can you please share the sp.js code also .
  • Howard,

    If you please share your js code then it will be very helpful .

    I am using gdoc as below but looks like your code is something different .


    <iframe src="" style="width:600px; height:500px;" frameborder="0"></iframe>

    Thanks for this nice post .



  • Udayan,


    The code simply writes in an embed element, but has the option of using gview also.


    I updated this post with more code and details:





  • I do not have a "Utilities Library" under the "All Site Content". Under "Document Libraries" I have "Documents", "Style Library", Templates" and "Web Pages". Under "Picture Libraries" I have "Images".

    I may be able to "Create" a library, but I'm not sure which one I should create. "Web Page Library"? And even if I did create a new library and call it "Utilities", where do I get the sp.js file from to place in there?

    And yes, I did upload a PDF file to the Document library.

    Is this a limitation of the P1 Plan?

  • I tried as you suggested and got "The webpage can not be found". That is because I do not believe I have a "utilities" directory. And without a "utilities" directory I can't place the pdf.aspx file into it. Nor do I have a copy of the sp.js file to put there either.

  • Howard,


    If there was a problem with P1 plan I would think the solution would have failed to activate or the new site would have failed to create.


    Did you create a new site using the PDF Site Template?


    The site template includes a Doc Library called utilities which gets created at the subsite root.


    If you create a sub site using the template called 'Docs' then the utilties lib will be here:



    The site template also includes a library template called 'PDF Documents' that you can use the create new PDF enabled Doc Libraries.



  • Josh,

    The solution can't be activated in a P1 account. At least not in mine (but then mine is messed up and doc libraries won't even load anymore............)

    I tried the utilities template too and that throws an error.   |     |  Get more out of Office 365

  • I am new to Sharepoint so I have no idea what your talking about. I did not create a new site using the PDF Template. I guess they must have been in your "Solution" - I haven't used "Solutions' so I didn't even try to use it.

    Anyway, I had some time to look at your latest update that included the javascript and the method you used for parsing out the file name from the URL. I really think you made it alot more difficult than it needed to be. Here is the pdf.aspx file after my modifications:





         <script type="text/javascript">


            document.write("<embed type='application/pdf' width='100%' height='100%' src='/Documents/"+pdf[1]+"'/>");




    Two lines of code. If you ask me, it's a lot easier to understand.

    Placed the pdf.aspx file in the Documents Library of my website and it works just fine.

    I'm sure you had your reasons fo doing it the way you did. If you would care to enlighten us or point out any deficiencies in my solution I would be more than happy to learn someting new.

  • Sorry....Please use these lines of code instead:


           document.write("<embed type='application/pdf' width='100%' height='100%' src='"+pdf[1]+"'/>");

    This will allow you to use the absolute or relative address to the PDF document:

    http://<yoursite><pdf file> or just /Documents/<pdf file>

  • Hi Howard,

    Glad you found a solution that works for you.  I just always use the getQueryString code because it allows more than one query string.  In this case, presently there is only one query string so fewer lines is fine too.

    Yes, the file query string is relative so in your case you could supply only the 'PDFFileName.pdf'  if you want because you put the pdf.aspx in the same document library.  However, if you want to use the same pdf.aspx to view PDF files from another library, then you'll have to provide the whole url to the other file in your query string.

    That's why I put it in a separate utilities library so the file variable is alway relative to the site and there will only be one copy of PDF.aspx in case I want to make changes.

    In sharepopint a 'solution' is a set of functionality saved in a single file that can be uploaded and activated for later use on a site.  The PDF Site Template is a solution that adds a new site template to your templates gallery making it available to use when creating new sites.  When you do so, many artifacts are created in that site including the following:

    Utilities Library containing pdf.aspx and scripts

    Customized Documents Library 'PDF  Enabled'

    PDF Document Library Template (for creating new doc libs 'PDF enabled')

    New Item Workflow which sets a PDFLink column to the PDF.aspx having the correct relative file querystring

    In a nut shell this makes the PDF file display in browser by clicking on the list item nearly the same as it does when Browser File Handling is set to Permissive.

    Please let me know if you have any questions.



  • I've had a chance to test this on multiple browsers:

    It works in IE, FireFox, Safari and Opera, but it doesn't work in Chrome.

    I'll go back and check your version. Any ideas why it doesn't work in Chrome?

  • Tried jbooker's doesn't work in Chrome either. Chrome doesn't have alot of optional settings. I didn't see any that I thought my prevent the page from rendering as the ohter browsers do. Anybody got any ideas?

  • Howard,

    You could try an <object> tag instead of <embed> or use the gview option.

    <object data="filename.pdf" type="application/pdf" width="100%" height="100%" ></object>

    I haven't tested, just a suggestion to try.


  • Just loaded up your PDF Report site template and works like a charm!  Even in my IE9 (in which I had a weird problem when previously linking to your site for the rendering).  Thanks a ton!  I will let everyone know about this!

  • I did try the <object> tag, still no-go in Chrome. I'll try the gview next.

  • I tried the gview method and received a "404 Not Found" error. Did a quick "Google" and I believe I found the web page that Udayan "cut and pasted" the code from:


    <iframe src="" style="width:600px; height:500px;" frameborder="0"></iframe>


    Unfortunately, it looks like he didn't read far enough down the page because three paragraphs down I found this:


    Update (Sept. 25): The viewer is now available at You can use it to embed PDF documents, PowerPoint presentations, and TIFF files.


    What I found more helpful was the Google Docs - Viewer webpage itself at What I found there was that the url parameter had to be URI encoded (using the encodeURIComponent() function):


    <iframe src="" width="600" height="780" style="border: none;"></iframe>


    Unfortunately, that put me right back in the same place that I started from, being twarted by the Browser File Handling setting, because this now gave me the following error message:


    This content cannot be displayed in a frame

    To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame.


    So, I guess those using the Google Chrome browser are going to be left out.

  • Howard,

    Thanks for the update.  This is all specific to chrome, correct?  

    It works fine in IE.  I believe /gview and /viewer both serve the same viewer control so there is nothing wrong with using either.

    I have no trouble supplying non-encoded URLS.  

    I have never seen  'This content cannot be displayed in a frame' message.  That's only happening in chrome right?

    Does this page work for you?

    I don't use chrome nor gDocs so I can't help much, but it seemed to work so I included it as an option in my code for google lovers...not that there are any of those folks around here.

    "I guess those using the Google Chrome browser are going to be left out."  ...Sounds like a plan to me.  :-)



    One thing I have found is that gview only works for anonymously accessible pdf files.  Public Site only.

    Even if you are logged into your private site in another IE tab the gview fails due to permissions.



  • Hello Joshua,

    I'm not able to go further than uload and activate the solution. When I try to create a site using your solution it gives the following error:

    In E3: ".....the solution {b5934f65a844-4e67-82e5-92f66aafe912} must be activated in the site...."

    In P1: the same message but with differen code " {068bc832-4951-11dc-8314-0800200c9a66}"

    My default language is Dutch.

    Thanks in advance...

  • Jimmy,

    Thanks for trying this solution.

    These are hidden features which need to be activated on the site before you can create a new site from the template.  One of the biggest headaches in creating soloutions for O365 is that templates save all active features as prerequisites, yet there's no documentation of what features enable other features and how to shut them off.  I did my best to disable any uneccessary features before creating the template, but there could be features enabled in my environ which are not in yours.  This issue causes unecesassary incompatabilities between P1 & E3 as well as between public and private sites.


    Therefore E3 is the only account type on which I can say for sure the PDF Site template will work.

    Luckily these are SP2010 OOB features so we can identify them.  Many times the errors are for undocumented hidden O365 features which are all a mystery.  




    Routing Workflows - SharePoint 2010

    This is a hidden feature, I don't know which feature activates this one(?)



    Enhanced Theming -

    This is a hidden feature activated by the SharePoint Server Publishing Infrastructure feature

    Please take a look at the Site Collection Features page of your E3 site and compare your active features to mine which you can see here:


    If you see something active on mine that is not on your then activate yours and try the PDF site again.  If that doesn't work then active the SharePoint Server Publishing Infrastructure feature and then try again.




  • Joshua,

    Thanks for the quick reply. I had to enable workflows in order to have your solution working. It's working fine now. Good job.


  • Sorry, I haven't responded sooner but I've been down with the flu for almost the last week.

    Anyway, I found the problem with the Google Chrome browser not rendering the PDF files. The Adobe Reader plug-in was disabled in the Google Browser.

      Options > Under the Hood > Privacy >  Content Settings > Plug-ins  - then click the link for "Disable individual plug-ins..."

    I found that the Adobe Acrobat plug-in was disabled. I enabled it and now PDF files render as expected in Google Chrome.

    It's funny because there is also a "Chrome PDF Viewer" plugh-in. If you enable the Adobe Acrobat it disables the Chrome PDF Viewer and the PDF documents renders. If you enable the Chrome PDF Viewer it diables the Adobe Acrobat and you get the grey screen I've been fighting all this time. If you disable both you will get an error message stating "Missing Plug-in".

    Thanks for everyone's assistance with this.

    I really wish the Microsoft would leave those of us who are better served with Office Live Small Business where we are instead of forcing us to manually port everything over to Office 365. There's nothing here that I really need and some things that I really need that are not available. If it ain't broke don't fix it.

  • Hello jbooker,

    I love that you have a solution – this is a lifesaver for my use of O365.  Unfortunately, my business use only needs the P plan and I’m experiencing the same error:  “The site template requires the Feature {068bc832-4951-11dc-8314-0800200c9a66} be activated in the site collection.”

    I see only 7 items in my Site Collection Administration > Features page, compared to the 20 in your .png image.  My guess the delta is due to the difference between the P1 and E3 plans.  Thus, I’m unable to access nor activate either of the two SharePoint services that helped Jimmy:  

    1)  SharePoint Server Publishing Infrastructure

    2) Workflow to activate them and then test to see if the solution then works

    Do you have any suggestions for how to enable your solution on a P1 plan?  Perhaps to simplify the solution to eliminate the dependence on those services?  I’m challenged to justify 4x the cost ($6 for P1, $24 for E3) for the business to have access to .pdf’s in the browser – seems cost prohibitive.  

    I’d GREATLY value your ideas on a .pdf browser solution for the P1 plan!


  • Hi Chuck,

    I'd have to setup a trial P1 plan and get it to go then provide a new template.  This whole feature dependency hassle is something MS has to fix.  At least they could document  which features are on which plans so developers could setup an environ to produce expected results.

    What's your imediate get PDFs to open in browser form your Public Site or to enable one-click PDFs automatically from your Doc Libraries on your Team Site?

    The former I could walk you through and latter will take me some time to get it going on P1.

    Unfortunately, I don't see myself doing P1 for at least a couple weeks.


  • Hello Josh,

    Great and thank you for the prompt response.  My need is to enable one-click PDFs automatically from non-public Doc Libraries on my P1 Team Sites.  I'll stay tuned, to this thread if you do get to developing a solution on teh P1 plan.  It would be worth money to create a P1 solution!  

    Thank you,


  • Update:

    After investing much time reading Community threads and in web research, I concluded that the MSFT solution for viewing a .pdf in the browser is not likely to happen in the short term.  I’m hoping with the next big version upgrade to O365 there may be an update.  Thus, Josh’s workaround is the only option I found.  I purchased an E2 plan at $16/month which provided me access to the site collection admin page where I activated the following two features:

    1)  SharePoint Server Publishing Infrastructure

    2) Workflow

    Then at Solutions Site Settings > Galleries > Solutions I uploaded Josh’s PDFDocumentSite.wsp file, activated it and created a new sub site.   Opened the document library in the site, uploaded a new .pdf file and…..Viola!  I can now open the .pdf file in the browser from my E2 O365 site.  

    Conclusion:  E2 at $16/month plus Josh’s solution is the most economical way to use O365 for .pdf in the browser!  Benefit is that you can leverage SharePoint User Permissions to manage secure access to your .pdf files and links to those files.  The latter was my main concern.

    THANK YOU Josh for your work on this.  Please let the community know if you develop a solution that works on the more restrictive P1 plan.


  • Hi All,


    This is a more complete PDF solution for Office365 which works on all subscriptions (P1-E3).



    PDF Utilities Library Template


    • Install by simply creating a new Document Library from a Template.
    • Enables Viewing PDF Files in Browser anonymously and Authenticated.
    • Document Hyperlinks Automatically work for PDF files
    • PDF Icon Automatically Appears
    • New Menu Item 'Open PDF in Browser' Appears
    • No Site Template, Workflow, Content Type or Doc Library Template required


    Please use this solution and not the original one at the beginning of this thread.




    0 out of 1 people found this post helpful.

  • Ok, so i tried to install the complete solution. - Ran into a couple of snags that probably should be clarified for non-programmers.

    Firstly, the Link provided for info if you dont have US-english isnt really self-explanatory, however after pondering what was the problem (changing LCID in manifest file) and reading through the page sometimes i got it - you need to rename the .stp file to .cab and extract the manifest file, change the LCID in the file and then get it back into the .cab, then rename it back to .stp and upload it.

    Ok, so now to my problems. - After doing this i cannot get the solution to work. - .pdf icons wont show, and when i press the pdf-file it still wants to download (the filename does not get passed to your .js)

    So, to clarify if i did everything right;

    1. I opened the manifest file, and did a search for 1033 (US-english LCID) replacing 3 occurences with my LCID (1044) - Am i supposed to replace all 3?

    2. Further things got complicated when i started to investigate why it didnt work, because my site looks like this;<site> so my utilities directory is

    After finding several absolute paths in manifest.xml pointing to /Utilities/ i changed these paths to /companyname/Utilities and reinstalled,, but it didnt seem to do the trick.

    I also tried copying the /companyname/Utilities directory to /Utilities to see if that would work, however, no go.

    Any ideas about it?

  • Hi KKL,

    I've not done the language change thing, but I believe you have the steps correct:

    "you need to rename the .stp file to .cab and extract the manifest file, change the LCID in the file and then get it back into the .cab, then rename it back to .stp and upload it."


    You don't need to change anything else like the /utiltites paths or anything in the manefest.  You will know when the language change was successfull by the fact the utilties template displays in the create library gallery.


    So you need to reverse all your changes to the manefest except the 1044 changes.


    Then it's best to create the utilities lib at you top level site here:


    to do so go here and then click the create link:


    Then you're ready to move tot he next step.


    Let me know,


  • This is by far the best PDF solution to date for O365.  Everything works fine for me, although there are select folders within the libraries that do not seem to automatically work with the solution.  The "Open in PDF" option works 100% of the time, but I'm referring to the icon appearing and the file link actually opening in PDF by default.  Any file with a "." anywhere in the filename will cause the automatic handler to fail, but again the manual opener still functions.  Rename the file and everything works great.

    BUT - I have noticed that immediately after adding the Content Editor web part, the "Library Tools" header disappears from the top of the screen.  This removes the user's ability to "open in explorer" which is what 99% them click that library button for.  Not sure if the scripts are conflicting or what.  You've been a real hero so far jbooker - do you have any idea why this is happening?


  • Hey Art,


    Thanks for trying the solution and for your kind words.
    I learned of these issues yesterday.  I don't have a fix yet as I'll have to recreate them in my environ and examine the html source to work around it.  The script fails when there is a folder in the doc lib view.
    The multi-dot thing is a toss-up.   The script parses the file name to see if it's .pdf
    Unfortunately with client side script, all I have to work with is the HTML that sharepoint outputs which is less than stellar.  I could code it for the last dot, but then if the doc is checked out and the checked-out-to person has a dot in their full name, then it would fail.  I just didn't have the time to debug this anymore.  So I gambled and figured there were fewer folks using dots in file names than those with middle initials.
    If you have many the former and not so much the latter than I could help you make a simple change to the code.
    If you're crafty, you could modify \utilities\pdf.js to solve these issues. 
    It may be a while, but I will let you know when I get to fixing these.


    The disapearing ribbon is a mirage.  Try selecting anything within the Doc List and you should see the ribbon tabs apear.  I believe this is expected behaviour as the ribbons are context sensative to what is selected on the page.  After adding the CEWP, you now have two webparts so the doc list view must be selected to get the ribbon.


    Let me know if I'm wrong on this.


  • I put my web designers on your script and the folder-fail issue has been resolved.  They tell me that it was a relatively simple matter, but I can send you the file if you would like to see the fix.  I saw what you meant with the Library Tools bar and have informed our users.  The period issue is so minor that I'm not sure it's worth bothering with.  I'll just tell users not to use extra periods in the filenames, along with "&", "@", etc.

    Thanks for a great job with this issue.  It looks like it's been a one-man campaign to address the problem, and it's safe to say that you're the only one with a solution canned enough for widespread use.  Shame though...I was so proud of the workflow we had built....  Ah well - your latest solution is lightyears better.  Hopefully it stays functional after the upcoming "upgrades" to O365.

    Let me know if you want that file.  And thanks again.  -A

    Art Smith, Director of Operations for CVR

  • Hey Art,


    Another user has fixed the folder issue today as well so it's turning into a shared effort which is nice.  The extra dot is fixed as well.  I will post the fix on my site ASAP. The last issue I know of is a failure when the doc lib is in grouped view.  Check it out if you have idle designers.


    Please do send me the file if you would.  It's nice to see how you resolved it.


    Send me your email here and I'll reply plus I'll keep you posted about updates:




  • The new pdf.js is working great.  This is now the ultimate PDF solution for the 365 cloud - it's 100% transparent to the clients.  Opening PDF files feels quicker, too.  Must be my imagination...

  • Folks,

    If you have implemented the complete solution, then you may wish to get the most recent update.

    I added another step to the instructions.  This is to update your version of the javascript.

    Special thanks to Randall for working to fix:

      • Issue with Links and Icons when Folders exist in Doc Lib View

      • Issue with multi-dot file names

      • Issue with browser viewing when doc is checked out.

    Upload the latest version of pdf.js to your utilities library.

    •download it here:  (Last Update 2011.10.14)


    UPDATE :

    To get most recent version of utilities files goto this site and proceed with step 2:


    Last remaining issue I'm aware of is faillure when doc lib view is grouped.  Anyone? anyone?

    Seriously, thanks to everyone for your help and suggestions.



  • Update:

    The failure when Document Library view is Grouped has been fixed (mostly)  Also, the Icons and links work in Firefox now.

    Upload the latest version of pdf.js to your utilities library.

    •download it here:

    (Last Update 2011.10.17)


    UPDATE :

    To get most recent version of utilities files goto this site and proceed with step 2:


    Have a nice day!


  • One more error has been discovered today.  A file or folder with an apostrophe in the name will cause the script to crash.  I'm guessing the apostrophe causes the script to think everthing behind it is a comment and stop running, but I'm no programmer.  The simple solution is to remove the offending mark, but I thought you should know.

  • Hi Art,


    Thanks for bringing this to my attention.


    This is fixed.  Please upload the latest pdf.aspx to your Utilities Library.


    Right Click the following link and 'Save Target As'


    Then go to your Utilities Library and Upload that file and try a PDF with apostrophe again.

  (Last Update 2011.10.19)


    UPDATE :

    To get most recent version of utilities files goto this site and proceed with step 2:


    Let me know how it goes.




  • As usual, it works like a charm.   Great work!

  • Just found this "complete solution", about to try it out. Can't believe MS have not included this capability.

  • OK, i have run into a problem. Please be aware i'm new to Sharepoint and Office 365 so it may be someting really basic.

    I have an o365 trial, plan P1. I'm on about Day 40 so the trial has expired but i'm within the period where it still appears to work OK.

    Step 1, Downloaded UtilitiesLibrary_20110930.stp to my local PC OK.

    Step 2, Within o365 went to <YourSite>/_catalogs/LT and uploaded above library OK. I used the "Upload Document" button off "Library Tools > Documents" toolbar, is this correct?

    Step 3, Went to <YourSite>/_layouts/viewlsts.aspx and created the "Utilities" library as shown in instructions. I got the "An unexpected error has occured" but ignored this as per the guide. The "Utilities" library is now listed below "Libraries" on the left hand navigation bar (don't know correct term!) but if i click on this library there are no files listed within the library. In other words, within jbookers instructions the screen grab of "Website > Utilities > All Documents" shows 5 files, ICPDF, jquery_1.4.4, etc , but on my o365 there are no files listed.

    I have read all this thread and don't see anyone else having this trouble, any pointers to what could i have done wrong?

    Many thanks, Guy

  • Hi Guy,

    Thanks for trying the solution.

    Okay, so you're doing great.  Unfortunately, for some P1 users the error when using my template to create the library results in a library with no files, yet for others the files are created and all is good.  I'll add this to the many other issues with using templates in o365.

    Anyway, I've abandoned the template method and reworked my instructions into 2 steps the first of which is to create your own doc lib called utilities.  You've done that.

    The second step is to download the zip file from my site, extract them and then upload them individually to your Utilities Library.

    This should work well for folks who want to install updated versions of the scripts by simply repeating step 2 to overwrite the Utilities Files.

    Please go to my instructions and carry-on with step 2.

    Let me know how it goes.


  • Hi jbooker,

    Like everyone else, I'm grateful for your time and effort solving this perhaps tiny but albeit huge problem we have with o365.

    Now to my own implementation. Our main document library uses "document sets". Before I try to implement your solution on this type of document library, do you have any caveats concerning your solution on document sets?



  • Kanystrom,

    I haven't tried this on a document set view.  It works with folders and on grouped views.  It's easy to remove the affects should you have a problem by simply removing the content editor web part from the page.

    Worse case is the PDF related enhancements simply fail.

    Let us know how it goes.



  • Hi again,

    It worked beautifully. My users are already providing enormously positive feedback. How Office365 handles PDFs has been nothing short of a disgrace. With your solution in place we can love Sharepoint unconditionally :-)

    One more thing, though. And this might be something that has been discussed earlier. When I implement your solution on our main document library, the shortcut to the different views disappear from the breadcrumbs. Instead, I know have to mark a document in order to change the ribbon and there get to the views. Is there anyway of getting the views back to the breadcrumbs?

    Many thanks for your excellent work and immediate feedback,


  • Andreas,


    Yes the behaviour you describe (Missing Library Tools & Breadcrumbs View Selector) are by design in Sharepoint, albiet lazy design, unfortuneately.


    This is because more than one web part exists on the page.  A lazy effort to handle the case that view selection is not applicable to the selected web part.  Could they not have made it work regardless of selected part when the page is a Doc Lib View Page?  That's what the page will always be regardless of how many wps I may add.  Silly.


    Basically, after you add another webpart (CEWP in this case) the Document list view must be selected to see the contextual Library Tools.  I worked out a short script to select the WP, but haven't tested on many views yet.  You could try adding this to the PDF.js and see if it behaves well on your site:


    <script type="text/javascript">
    function SelectWP(){
    //select first webpart
    var wp = document.getElementById("_wpSelected");
        if (wp != null){
     wp.value ="MSOZoneCell_WebPartWPQ2";
     SelectRibbonTab('Ribbon.Document', true)
     ExecuteOrDelayUntilScriptLoaded(SelectWP, "sp.ribbon.js");


    Basically it selects the document list view wp and then shows the document ribbon upon opening the page.  If you click outside the list view the ribbon will disappear again because it's contextual, but at least it appears upon entry which may keep folks from scratching their heads trying to find the upload button.


    After some more testing I'll probably add this to my PDF script.  Your feedback is appreciated.


    As for the view selector, I've not delved into it yet nor have I found anyone else who has.  Some day maybe.

    Check this out:


    I'm sure there's a away to turn the view selector back on in javascript, but I haven't found anything.



  • So after having some time to revisit this, i got it to work with your newest version without too much hassle. - Love the solution :)

    However, i found out a couple of things im not sure is expected behaviour or not.

    Firstly, my site is organised in a way like this: Sharepoint site->Document site->Multiple Document Libraries, not sure if this is an unusual way to organize it.

    It seems that the Content web-part cannot be added in the "root" of the document site for it to work (On the page with the "Relevant Documents" web-part), so i have to add it to the root folder of every document library separately - is this the correct way to implement it? - Might be wise to mention in the setup docs if so that you have to add it to every library if you have multiple ones.

    Also, this leads to the solution not working in the "Relevant Documents" web-part - but thats probably expected?

  • Hi again Josh,

    The PDF-solution is working great -- for my Windows-users. The few, but hardy, mac-users we have are not equally satisfied. When OS X users click on a PDF, they get a "plugin does not exist" comment from Safari and Google Chrome shows a blank page. Is there any way to get your script to work for Apple users?



  • @KKL,

    Yes you have to add the Content Editor WEb part to every page that you want the enhancements.  The alternative is to add the script reference to your master page using sharepoint designer.


    Can they open PDFS in the browser from other websites?  Chrome has a built-in pdf viewer but you have to enable it in the settings somewhere.  Safari may have the same, I don't know.  But if they can open PDFs in browser from other websites, then they should be able to open using this solution.


  • Josh,

    Yup. No problem opening PDFs from other sites in Safari and Chrome. Is there anything in your javascript (I'm not a programmer) that sends commands to Windows-specific solutions?


  • Andreas,


    It has worked in chrome for other users once they enable the PDF plug-in.  Are you sure PDFs are opening in the browser from other sites vs. downloading & opening locally in Adobe?


    The script simply embeds the PDF in the HTML which means it relys on a client-side browser plug-in such as adobe acrobat plug-in for IE or the built-in one for chrome (when enabled).  It will not work if your browser settings are to download and open locally.

    Double check the Chrome setting:

    To enable the built-in viewer, enter about:plugins in the address bar and click Enable underneath the entry for “Chrome PDF Viewer.” The Adobe Reader plug-in is supposed to be automatically be enabled, if you have it installed. 

     Correction:  It's the adobe plug-in for chrome not the built-in one that works.  See the post in this thread :




    Try these options for Safari:



  • Hi all

    I've tried this solution on my computer with IE9 and it works properly. Thanks to Josh for his useful solution. But I've faced and additional issue: when I follow the instructions from Josh, in the docs libraries I've installed the solution I've lost the upper ribbons to get into de library configuration, alerts, Outlook connection, etc.


    The library looks like that:



    What can I do to restore de upper ribbons? I'm positive they're quite necessary to work with the library.


    Thanks again for your support.


    Best regards

  • Hi JI,

    Glad you like the solution.

    You will see a discussion about the ribbon issue in this thread above: Posted by jbooker on 2011-Oct-25 9:33 AM  

    Basically this is by-design behavior in Sharepoint 2010 (unfortunately).  If you click on the library list view the ribbons will appear.  

    You could try to add the script in that post which selects the list view webpart upon opening the page which will display the ribbon.

    I would like to add that to my script, but havn't had time to test and didn't get any feedback from others about it yet.  Feedback appreciated.



  • I did test the script for putting the ribbon back, aand it worked like a charm! - Simple cut-and-paste job.

    Im running O365 E3 plan.

  • Thank you again, Josh. I try by my own too and I'll bring you back my feedback.


  • Thank you, Joshua. Tried that solution and it works as is should have by design :-)

  • Really great job, Josh! We've tried the other script and that all works true good. Many, many thanks.


  • KKL, Ignacio, JI,

    Glad it's working. Thanks for the feedback.

    Have a great day!


  • In order to get the complete solution to work in my P1 environment, without any programming knowledge I needed to search for /utilities and replace with /teamsite/utilities in the pdf.js file. after an upload everything seasms to be working. It is also working seamless on iPad.

    Thanks for making this simple.

  • Ray,

    The script assumes you've created the utilties library on your top level site.  For P1 that is your public website.  This is so you can use the same relative url in every page on every subsite.  What you've done is fine, but the enhancements won't work on your public website pages.

    To correct this, create the utilties library on your public website.



  • Hi Josh,

    We are brand new to Office 365 and Sharepoint, and in an environment where we'd rather not have the material in the pdf files downloaded back to the local workstation once it's been uploaded to Sharepoint.  (Just seems a waste of time not to mention risky!)  I implemented your solution for the Library section and it seems to work as promised--although I do not see an Option to open PDF in browser--the familiar pdf icon and ability to view in browser work as promised.

    My challenge is how to have this functionality be duplicated for one of our calendars.  In our implementation we've gone from Public Folders to having our corporate planning calendars in Sharepoint.  However, we attach many files to our events and many are pdf's as well.  I tried adding the webcontent to the bottom of the calendar page, but that did nothing even after I modified the pathname to include /library/utilities/pdf.js.  Any help you can offer won't go to waste!

    You're a Christmas angel!



  • Hi Mary,

    The pdf.js assumes you've created the utilities at your top level site.  For P1 this is your public site I would suggest creating it there so you can resolve the file using the relative URL:


    in the Content Editor.  This should fix the Open in Browser Menu Item.

    As for PDFs attached to Calendar Events, I'd have to spend some time on that.  Which I don't see myself doing anytime soon.  If you have crafty web designers or if anyone reading this wants to give this a try, here are a few hints:


    The edit form looks like this and the attachments appear at the bottom.  It's the href of this link that needs to get changed to that of the pdf viewer page.


    Here is the source.  The href highlighted needs to get changed to:




    Something like this may work (?) Air code, I have not tested this, it porlly doesn't work, but it's close.


    <script type="text/javascript">
    //Create Array of All <a> Tags
    var a = new Array();
    var a=document.getElementsByTagName('a');

    //Loop through all tags using a for loop
    //alert (a.length);
    for (i=0; i<a.length; i++)
    //check for href attribute
    var h = a[i].href
    if (h!=null)
     //check for pdf extension
     var fileExt = h.split('.').pop().toLowerCase();
     if (fileExt == "pdf")
     //change link to use pdf viewer page
     a[i].href = "/utilities/pdf.aspx?file="+h;


    Lastly, you have to figure out where to add this code to the page.  Will it work on the Calendar.aspx or not?


    If not, it's probably easiest to add it to your custom master page using Sharepoint Designer.

    Have a great day.



  • I have implemented this solution fine the issue I have is that after adding the content editor webpart focus to the document library webpart is lost and the 'documents' & 'library' taps disappear. Is there a way to set the focus to the document library again?

  • 4114n,

    Please see the following post in this thread:

    Posted by jbooker on 2011-Oct-25 9:33 AM  


  • This is for Mary, Simon and others who've requested the ability to enable browser viewing of PDF files attached to list items from form pages.


    To do this you need to:


    1) Implement the PDF-Complete Solution here:


    2) Alter the Display and Edit forms of the respective list like so:


    Have a Great Day!



  • This is a really nice solution, but in my sharepoint, I have a lot of different document libraries in many subsites.  What a mess!  So I added the reference in my master page.  When I load the page, I'm getting this error.

    Can you help out?  I don't know anything about Java Scripting.  I have downloaded the newest version of the 3 files (dated 10/24) under the complete solution.

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; MS-RTC LM 8)

    Timestamp: Thu, 15 Dec 2011 11:05:47 UTC

    Message: Syntax error

    Line: 1

    Char: 1

    Code: 0


  • Sharon,

    I answered your other thread:   |     |  Get more out of Office 365

  • Thanks for your help mch.

    It sounds like Sharon's issue is that she has many Libraries and the masterpage option would be helpful to avoid having to add the Content Editor to every doc lib view.

    I havn't documented the masterpage option in this forum nor on my website.  To do this requires a change to the pdf.js file.

    1)  Use notepad to remove the <script></script> tags from the pdf.js file (2 of each I think)?

    2) You add this code using SPD to reference the the script in bottom of  v4.master (just after the </body> ) like this:

    <script type="text/javascript" src="/utilities/pdf.js"></script>


    Sharon, I'm guessing you need to do step 1.


    Hope that Helps,


  • Hey Josh,

    It works in the master page as you describe but it looks like you have to add it to each sub-site's v4.master file. So I guess the best option would be either make an adjusted v4.master available to every sub-site or create the libs from an adjusted template.


     |     |  Get more out of Office 365

  • Hey Matt,

    I don't have time to test this right now, but you may be able to inherit the parent site master page by navigating to here on subsite:


    Like so:


    Can't remember if this only works for site collections with publishing feature activated(?)  If so, it's not an option for P1 subscrptions.


  • Hey,


    I applied the Office365 PDF Complete Solution on our sharepoint site. It works fine for the for the Documents Library without grouping. Some of our Doc lib grouped by categories. I have to close and expand the group twice for the java script applied to the icon and file name link. Any idea about this issue?


    Thanks John.

  • Hi John,

    I noticed the behavior you describe.  I spent a while and made some improvement, but never solved the problem completely.

    Sharepoint runs some javascript to display the contents of a group dynamically upon expanding.  My script ties into this function and fails to apply the enhancements the very first time you expand a group in the library.  After that, It works for other groups first try and works upon the second time you expand the first group.  

    It has something to do with the rows not being on the page when the script runs I think.  I just ran out of time to debug this.  If your handy with javascript maybe you can figure it out and contribute a improvement.

    The menu option generates in script every time you drop down so it's unaffected.

    Perhaps someone in the community will have the skills & time to work through this.


  • Josh - thanks so much for this solution. We have 40 site collections all with subsites and tons of libraries and Microsoft really left us to die here. At least your solution gives us a ray of light.

    One question I had that I didn't see brought up here - is there a way to edit the .js file to have the PDF open in a new window. This way we don't have to instruct users to hold down CTRL.

    Thanks again for all your efforts.

  • I think I did what you suggested, but am getting the following error (at least it's moved)


    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E; MS-RTC LM 8)

    Timestamp: Mon, 19 Dec 2011 17:09:50 UTC

    Message: 'href' is null or not an object

    Line: 113

    Char: 1

    Code: 0


    Message: 'href' is null or not an object

    Line: 113

    Char: 1

    Code: 0



    Line 113 is var c = b.href;


  • @PartlyCloudy and others who've requested opening PDFs in new window:


    Please download this file and replace your /utilities/pdf.js with this one.   I tested minimally, please test it out to see if it opens in new window as you would like.  If it works well let me know and I'll update my utilities files to benefit future folks.



    @PartlyCloudy, with a large implementation, you may find it easier to apply the script to you master pages using sharepoint designer.  This requires a change to the script.  Please read above and let me know how it goes.


    @Sharon, The error is in the code that builds the menu drop down option.  Beside the menu option, can you tell me whether the icon and file link are working?  If not what are the symptoms for those enhancements?



  • Josh - the new file worked and opens the PDFs in a new tab in IE9 both when you click the filename and when you select Open from the drop down.

    I will try applying your solution to the master pages and let you know.

    Thanks again.

  • This is AWESOME!  No script errors, Icon is showing, Drop Down is working (5 libraries deep!).  THANK YOU SO MUCH!!!!

    This little problem was stopping me from publishing and allowing people onto our Office 365 Site.  

    Josh,  I'll be visiting your site and making a nice contribution for sure!

  • I have a requirement to open .pdf file in browser in sharepoint online that is linked to another .pdf file in a seperate folder(linked with bookmarks) . This is working fine in Sharepoint 2010 when browser file handling is set to permissive. above solution works perfectly for opening .PDF files in browser, however linked .PDF files will not work.

    Are there any solutions to open linked .pdf files in browser with sharepoint online.

  • Sowjanya,

    I've never used bookmarks in PDF files before, but I assume it may work if you could alter the urls in the pdf file to use the following syntax:



  • Josh,

    I need to alter bookmarks for many pdf files and tried creating a console application that can read and alter the bookmarks. I could retrieve the pdf bookmarks using itextsharp, however didn't succed to retrieve the bookmark url that will enable me to alter with above syntax.

    Any pointers to retrieve pdf bookmark url using itextsharp will be helpful.


  • Josh - just wanted to update you and people following this thread regarding the alternative for installing in each library.

    I installed the .js reference into the v4.master file (after the body tag) for each of my sites and removed the script tags from the .js file. This worked perfectly.

    In addtion to making this easier to apply to sites with many libraries, I also found a few other advantages over applying at the library level with the content editor web part. When applying at the v4.master level, all new libraries created, regardless of template used, will contain the fix automatically. This avoids having to recreate your library templates if you have a lot of them. Also, the problem with the ribbon losing focus as described in other posts here does not happen when the fix is applied to the master page.

    Thanks again for this solution - it was a life saver.

  • PartlyCloudy,

    Thanks for the update.  Glad you got it working well using the masterpage reference.

    Have a great day!


  • @Art Smith


    This is in reply to the following comment on the wiki page which is associated to this thread.  I didn't create the wiki, so I don't get notified of comments there...just happended accross it today.


    Please use this this thread for questions instead of the wiki page.


    Wiki comment:

  • You have outlined the problem perfectly.  Of course, since the editform.aspx and dispform.aspx are both pop up windows, the pdf_forms.js doesn't run on them and they cannot be edited via sharepoint designer.  So I'm stuck.  We have tailored an "issue" list to work as an ordering platform for our company, where orders are attached to a new issue list item for processing.  Most of these are in PDF, as they are scanned, and it would greatly help our order dept to simply click on them rather than having to save/open.  I have played around in the V4.master, but have no idea where to place the .js.  I tried to emulate what PartlyCloudy had done to put the solution at a root level, but couldn't figure out where the "body tag" ended.  Bottom of the page?  Right below \body?  Can you say "end user"?  lol.  

    Anyway - your continued help on the PDF issue is greatly appreciated.

  • Hey Art,

    Glad to reach you.  Because I tried the master page thing and it had issues, I wouldn't recommend that for forms pages unless you have time/skills to work it out.

    Using Content Editor on the Forms pages will work the same as you got it to work for the calendar forms.  As in this article:

    Here are some hints....

    To get your forms to open in the browser when the list is set to display modal pop-ups you can type the url directly into the browser address:


    to get that form into edit mode so you can add the CEWP add this:


    I think that's where you're hung up.  Now you should be able to follow the steps in the above article to reference pdf_forms.js in CEWPs on both the dispform.aspx and editform.aspx for the respective list.

    It's not nessessary in this case if you use the browser edit mode described above, but you can edit forms in SPD on the list settings page under forms:

    Also FYI, you can specify whether forms open in modal dialogs in the List Settings | Advanced Settings page:

    Let us know how it goes.


  • Opening the editform.aspx in the browser to add the CEWP was the key.  Thanks so much for your help!

  • Thank you!

    But I cannot use your solution with IE9 Russian. New IE9 window is opening and appears “Initialization”.

    That’s all. Is there some special settingа for non-English users?



  • Mikhail,

    There should not be any problem for non-english.  Do you have adobe acrobat plugin installed?  Are you able to open PDFs in the browser from other sites?  If you're on IE9 64-bit it won;t work because there is no 64bit adobe plugin.  Try on 32-bit IE9.


  • Thanks for answer!

    1. Adobe plug-in installed, ver.

    2. Windows 7 32 bit

    3. I’ll test pdf opening in IE9 from home pc

    4. Chrome doesn’t working too. Is there special settings for chrome?



  • Mikhail,

    Thanks for trying the solution.  It works for me in IE9 32-bit.


    Try this link:

    Does that work in IE9?


    Chrome needs adobe plug-in installed and enabled.  The built-in PDF viewer for chorme doesn't work.



  • Yes, I can open your file!

    And now I can open it with Chrome.

    And cannot open in IE. Check from home.


  • Mikhail,

    If you can open my file in IE but not your file then ther may be something wrong with how you setup the solution in your sharepoint.

    Did you implement this solution?