Pages

September 10, 2018

Fixed Issue: JS script unable to edit PDF document in SharePoint

 Setup:

- SharePoint 2013 site: has a library of PDF documents.
- Client machine: Windows 7 with SP1. Adobe Acrobat 2017 installed. Browser is IE 11.
- User calls a SharePoint page with custom JS script to open PDF documents in edit mode using the below js call:
editDocumentWithProgID2( _docRelativeUrl, '', 'AdobeAcrobat.OpenDocuments', '0', _hostUrl, '0');



Issue:

For many users the page script works fine. It instantiates the Adobe Reader ActiveX object to open the document in edit mode. But for some users the script cannot instantiate the Adobe Reader ActiveX object and will throw the following error message:

"The Document could not be opened for editing. A Microsoft SharePoint Foundation compatible application could not be found to edit the document."



 
Digging up:

First. I needed to make sure that Adobe plugin in IE does exist. From IE add-on settings panel, I can see the Adobe PDF Reader plugin (for 32bit and 64bit) with ver.17.8.30051.224877 where file is "AcroPDF64.dll".
What caught my attention is that on another good machine (where the script runs ok) there are 2 plugins: Adobe Acorbat SharePoint OpenDocuments (file is: "AcroPDF.dll") and Adobe PDF Reader plugin (file is "AcroPDF64.dll").

Second, I prepared a test page with script to detect and show the current version of Adobe plugin. That script is using getActiveXObject('AcroPDF.PDF') to instantiate the plugin if available then alert a message to show what version of Adobe plugin if exist.


Test Page Run #1 - on a good machine:

getActiveXObject('AcroPDF.PDF') -> returns [object]{}

Output: "Browser: ie, Adobe plugin installed: true, version: 11"


Test Page Run #2 - on the bad machine:

getActiveXObject('AcroPDF.PDF') -> undefined

Output: "Browser: ie, Adobe plugin installed: false, version: null"


Note: "AcroPDF.PDF" is used for IE 7 and later

So it is clear that JS couldn't find the plugin class, but I saw the plugin in IE add-on panel so what's missing?



Root Cause:

This is an Adobe plugin issue not a js issue. After inspecting the file system, I found that target (bad) machine is missing AcroPDF.dll (and other language-specific dlls too like: AcroPDF.CAT, AcroPDF.DAN, AcroPDF.FRA,..etc) in the following directory:

C:\Program Files (x86)\Common Files\Adobe\Acrobat\ActiveX

This could be because of bad installation for Adobe files, incorrect Group Policy setting or even Anti-Virus/Anti-Malware.



Fix:

Copy the missing AcroPDF.dll and other language-specific dlls to target (bad) machine under directory:
C:\Program Files (x86)\Common Files\Adobe\Acrobat\ActiveX



Final Notes:

Per testing I found that the site has to be added to 'Trusted Sites' zone in IE in order for the Adobe plugin to work correctly and edit required documents. Please check the Group Policy settings if they prevent that.

Recommended setting: To get rid of multiple logon popups after adding url to Trusted Sites, check the ‘Automatic logon with current user name and password’






4 comments:

  1. Hi! Can you possibly post the complete JSON/JS files needed to make this work? I am a complete novice but we really need this functionality.

    ReplyDelete
  2. Very Interested site this is. I truly Enjoy a lot reading your Blog. I will Bookmark your site for more reference.
    edit pdf online free

    ReplyDelete
  3. The customers should first discover some on-line PDF converter which has the power to transform PDFs to Phrase or Excel in an expert method. This on-line converter might be accessible freed from value or on fee of small cost. If you want to learn more about this topic please visit https://onlineconvertfree.com

    ReplyDelete
  4. Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained! cfa level 1 mock exam 2019 pdf

    ReplyDelete