Copy link to clipboard
Copied
A few months back I made the change to my DOCICON.xml file to enable the integration with Acrobat and Sharepoint to prompt the user to "Check Out and Open" PDF files in document libraries in Sharepoint 2013. It worked fine and as expected.
After applying CU's to Sharepoint up to October 2013, this function seems to have gone away. I verified that the DOCICON.xml settings are correct. Ex: <Mapping Key="pdf" Value="pdficon_small.png" OpenControl="AdobeAcrobat.OpenDocuments" />
I can still get the "check out..." prompt if I open the document libraries with Windows Explorer, but not when PDF's are opened directly on Sharepoint. I have a support case opened with Microsoft, but they seem to point the problem at Adobe.
I have verified that the AcroPDF.dll is on each client and is enabled in IE. The PDF files open with Acrobat, but the check out prompt is not showing up unless I open the Sharepoint library with Explorer.
Have tried different Acrobat versions (10 and 11) as well as different IE versions (9,10,11)..etc...and Windows 7 or Windows 8, but the check out function does not seem to work when opening PDF's directly from Sharepoint 2013
Microsoft support just helped me with this issue. A published fix is likely to come out soon. The following steps are just my re-write of their instructions. As with all fixes or workarounds, I recommend you test first.
Other things to be aware of before you implement this is that all PDF files will open with the "check-out" function whether or not your library settings say "open in browser" or not and I don't think any other settings will matter as the javascript file is controlling. Changes yo
...Copy link to clipboard
Copied
We have the same problem. We noticed it was no longer working after the March cummulative update for SP 2013. Have you found a solution yet?
Copy link to clipboard
Copied
We have a support case open with Microsoft and about a week ago, Microsoft confirmed a bug in the March 2013 updates. The java script is not executing a call to the active-x control on the client PC. We submitted the paperwork to get a hotfix created, don't know how this works with them, sounds like they have a committee to review requests like this, so I am hopeful we will get a fix soon, but no time frame given.
Another workaround is to search the document library and open the PDF's via the search results (assuming youi have searching enabled), then you should also get the "open" prompt.
Copy link to clipboard
Copied
Thank you for your response. Do you mind keeping us posted on any further details as you hear them?
Copy link to clipboard
Copied
Hello, has there been any progress made on this issue? I am expereincing the same thing in two different Sharepoint 2013 environments. I cannot open PDF files directly with Adobe Acrobat, however if I search for the document I can open them from the search results just as Eric Hallgren states above.
Copy link to clipboard
Copied
My last email from Microsoft was Jan 23, 2014. In that email they said that the support case was now submitted to the product evaluation group who will now triage the problem and come up with an answer as to how to fix the problem...meaning it may or may not be a hot fix...etc....as soon as I get an answer I will post it here....
Another option that I am using is to open the document library with Windows Explorer. This also allows the check-out option to work
Copy link to clipboard
Copied
Thanks Eric, thats great information! I look forward to a response from Microsoft, this has been a troublesome problem for us.
Copy link to clipboard
Copied
Microsoft support just helped me with this issue. A published fix is likely to come out soon. The following steps are just my re-write of their instructions. As with all fixes or workarounds, I recommend you test first.
Other things to be aware of before you implement this is that all PDF files will open with the "check-out" function whether or not your library settings say "open in browser" or not and I don't think any other settings will matter as the javascript file is controlling. Changes you make to the docicon.xml won't matter either.
STEPS
You need to create a javascript file, the contents are at the end of this post. Copy the contents between the “***” to notepad or other text editor and save it as “PDFFIX.js”.
Copy the file (pdffix.js) to your Sharepoint server - C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS
Run the powershell commands on your Sharepoint server below depending on what you want to fix, either a single library or site collection. You may also need to clear IE cache on your client.
Powershell commands assume admin and Sharepoint tools loaded or you are running from the management shell.
SINGLE DOC LIBRARY
$web = Get-SPWeb http://urltoweb
$list = $web.Lists["nameoflist"]
$field = $list.Fields.GetFieldByInternalName("LinkFilename")
$field.JSLink = "/_layouts/15/PdfFix.js"
$field.Update($true)
SITE COLLECTION
$site = Get-SPSite http://”yoursite”-no quotes
$web = $site.RootWeb
$field = $web.Fields.GetFieldByInternalName("LinkFilename")
$field.JSLink = "/_layouts/15/PdfFix.js"
$field.Update($true) #push change down to all lists
To uninstall the fix use this:
$site = Get-SPSite http:// ”yoursite”-no quotes
$web = $site.RootWeb
$field = $web.Fields.GetFieldByInternalName("LinkFilename")
$field.JSLink = ""
$field.Update($true) #push change down to all lists
*****CONTENTS OF PDFFIX.js*****
(function () {
if (typeof SPClientTemplates === 'undefined')
return;
var PdfCtx = {};
PdfCtx.Templates = {};
PdfCtx.Templates.Fields = { 'LinkFilename': { 'View': PdfClientLinkFilenameNoMenu } };
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(PdfCtx);
})();
function GetExtension(szHref) {
var sz = new String(szHref);
var re = /^.*\.([^\.]*)$/;
return (sz.replace(re, "$1")).toLowerCase();
}
var stsOpen = null;
function IsPdfClientInstalled() {
if (stsOpen == null) {
if (Boolean(window.ActiveXObject)) {
try {
stsOpen = new ActiveXObject("PdfFile.OpenDocuments");
}
catch (e) {
stsOpen = null;
}
}
}
return (stsOpen != null);
}
function OpenPdfInClient(pdfFileUrl) {
var fRet = true;
try {
fRet = typeof stsOpen.ViewDocument2 != "undefined" && stsOpen.ViewDocument2(window, pdfFileUrl, '');
}
catch (e) {
fRet = false;
};
if (event != null) {
event.cancelBubble = true;
event.returnValue = false;
}
return fRet;
}
function PdfNewGif(listItem, listSchema, ret) {
if (listItem["Created_x0020_Date.ifnew"] == "1") {
var spCommonSrc = GetThemedImageUrl("spcommon.png");
ret.push("<span class=\"ms-newdocument-iconouter\"><img class=\"ms-newdocument-icon\" src=\"");
ret.push(spCommonSrc);
ret.push("\" alt=\"");
ret.push(Strings.STS.L_SPClientNew);
ret.push("\" title=\"");
ret.push(Strings.STS.L_SPClientNew);
ret.push("\" /></span>");
}
}
function PdfClientLinkFilenameNoMenu(param1, param2, listItem, listSchema) {
var ret = [];
var fileUrl = listItem.FileRef;
if (fileUrl != null && typeof fileUrl != 'undefined' && TrimSpaces(fileUrl) != "") {
if (listItem.FSObjType == '1') {
if (listSchema.IsDocLib == '1') {
RenderDocFolderLink(ret, listItem.FileLeafRef, listItem, listSchema);
}
else {
RenderListFolderLink(ret, listItem.FileLeafRef, listItem, listSchema);
}
}
else {
ret.push("<a class='ms-listlink' href=\"");
ret.push(listItem.FileRef);
ret.push("\" onmousedown=\"return VerifyHref(this,event,'");
ret.push(listSchema.DefaultItemOpen);
ret.push("','");
ret.push(listItem["HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon"]);
ret.push("','");
ret.push(listItem["serverurl.progid"]);
ret.push("')\" onclick=\"");
var appInstalled = IsPdfClientInstalled();
var szExt = GetExtension(listItem.FileRef);
if (appInstalled && szExt == 'pdf' && browseris.ie) {
ret.push("return OpenPdfInClient('");
ret.push("http://");
ret.push(window.location.hostname);
ret.push(listItem.FileRef);
}
else {
ret.push("return DispEx(this,event,'TRUE','FALSE','");
ret.push(listItem["File_x0020_Type.url"]);
ret.push("','");
ret.push(listItem["File_x0020_Type.progid"]);
ret.push("','");
ret.push(listSchema.DefaultItemOpen);
ret.push("','");
ret.push(listItem["HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon"]);
ret.push("','");
ret.push(listItem["HTML_x0020_File_x0020_Type"]);
ret.push("','");
ret.push(listItem["serverurl.progid"]);
ret.push("','");
ret.push(Boolean(listItem["CheckoutUser"]) ? listItem["CheckoutUser"][0].id : '');
ret.push("','");
ret.push(listSchema.Userid);
ret.push("','");
ret.push(listSchema.ForceCheckout);
ret.push("','");
ret.push(listItem.IsCheckedoutToLocal);
ret.push("','");
ret.push(listItem.PermMask);
}
ret.push("')\">");
var fileRef = listItem["FileLeafRef"];
if (fileRef != null) {
var index = fileRef.lastIndexOf('.');
fileRef = index >= 0 ? fileRef.substring(0, index) : fileRef;
}
ret.push(fileRef);
ret.push("</a>");
PdfNewGif(listItem, listSchema, ret);
}
}
else {
ret.push("<nobr>");
ret.push(listItem["FileLeafRef"]);
ret.push("</nobr>");
}
return ret.join('');
}
************END CONTENTS OF PDFFIX.js***********************
Copy link to clipboard
Copied
There was nothing else you had to do?
When I try this and try to open a PDF I get
"There was an error opening this document. The filename, directory name, or volume label syntax is incorrect."
We are on 2013 SP1.
(I thought the url would be a clue as on this link (http://social.msdn.microsoft.com/Forums/en-US/545efcc6-b748-4df8-aee0-7f57f778ad1e/sharepoint-2010-o...) but having put an alert and making some edits to the js above, no matter what url I use it gives me the error)
I also have been trying to figure out what makes the search results different, to try to replicate that.
Chris Buchholz
Copy link to clipboard
Copied
Hi Chris,
I applied this fix on my test environment and it worked fine.
But, when I applied same solution on production, I faced the issue you have.
The problem was that my test is on http and production is on https.
I fixed this issue by replacing
ret.push("http://");
with:
ret.push(window.location.protocol + "//");
in PDFFIX.js file.
I hope it helps.
Regards.
Copy link to clipboard
Copied
Hiii..Thanks for sharing your ideas..
Regards..
QTP Training in Chennai | Software Testing Training in Chennai | Selenium Training in Chennai
Copy link to clipboard
Copied
Thanks Eric.
It is working fine from the document library now. However, it doesn't work if you open the document from the SharePoint Designer Task form.
Have you get any published updated from Microsoft?
Thanks,
Sohaib
Copy link to clipboard
Copied
@Not sure if anyone else ran into this issue, but it doesn't seem like anyone checked this code with a document library that contained folders. When I did, it bombed out. The fix was to completely remove the checking for a folder. This seemed to fix it right up. Not sure if someone forgot to code the RenderDocFolderLink and RenderListFolderLink functions or what exactly those are supposed to refer to but whatever they are, they don't work correctly and simply removing the entire checking for and individual processing of folders seems to work just fine.
Also, one other note, putting a link to the pdffix.js file in the Master Page seems to work just fine for sites that have Publishing feature active.
Copy link to clipboard
Copied
Smoupre,
Could you elaborate on what you removed to fix the issue with folders? I've tried removing various pieces of the code but still have the same result: It works fine intially, but after navigating any folders within a library, it reverts to the old (broken) behavior. Thanks for your time.
Nick
Copy link to clipboard
Copied
Thank you for posting this! It helped with my issue after migrating from SP2013 to SP2016. When the original fix was applied libraries with folders were getting a TypeError. I removed the sections you refrenced and ran the powershell script and everything worked great! Here's the code.
(function () {
if (typeof SPClientTemplates === 'undefined')
return;
var PdfCtx = {};
PdfCtx.Templates = {};
PdfCtx.Templates.Fields = { 'LinkFilename': { 'View': PdfClientLinkFilenameNoMenu } };
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(PdfCtx);
})();
function GetExtension(szHref) {
var sz = new String(szHref);
var re = /^.*\.([^\.]*)$/;
return (sz.replace(re, "$1")).toLowerCase();
}
var stsOpen = null;
function IsPdfClientInstalled() {
if (stsOpen == null) {
if (Boolean(window.ActiveXObject)) {
try {
stsOpen = new ActiveXObject("PdfFile.OpenDocuments");
}
catch (e) {
stsOpen = null;
}
}
}
return (stsOpen != null);
}
function OpenPdfInClient(pdfFileUrl) {
var fRet = true;
try {
fRet = typeof stsOpen.ViewDocument2 != "undefined" && stsOpen.ViewDocument2(window, pdfFileUrl, '');
}
catch (e) {
fRet = false;
};
if (event != null) {
event.cancelBubble = true;
event.returnValue = false;
}
return fRet;
}
function PdfNewGif(listItem, listSchema, ret) {
if (listItem["Created_x0020_Date.ifnew"] == "1") {
var spCommonsrc=GetThemedImageUrl("spcommon.png");
ret.push("<span class=\"ms-newdocument-iconouter\"><img class=\"ms-newdocument-icon\" src=\"");
ret.push(spCommonSrc);
ret.push("\" alt=\"");
ret.push(Strings.STS.L_SPClientNew);
ret.push("\" title=\"");
ret.push(Strings.STS.L_SPClientNew);
ret.push("\" /></span>");
}
}
function PdfClientLinkFilenameNoMenu(param1, param2, listItem, listSchema) {
var ret = [];
var fileUrl = listItem.FileRef;
if (fileUrl != null && typeof fileUrl != 'undefined' && TrimSpaces(fileUrl) != "") {
ret.push("<a class='ms-listlink' href=\"");
ret.push(listItem.FileRef);
ret.push("\" onmousedown=\"return VerifyHref(this,event,'");
ret.push(listSchema.DefaultItemOpen);
ret.push("','");
ret.push(listItem["HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon"]);
ret.push("','");
ret.push(listItem["serverurl.progid"]);
ret.push("')\" onclick=\"");
var appInstalled = IsPdfClientInstalled();
var szExt = GetExtension(listItem.FileRef);
if (appInstalled && szExt == 'pdf' && browseris.ie) {
ret.push("return OpenPdfInClient('");
var url = window.location.href;
var arr = url.split("/");
var baseHostNameWithPort = arr[0] + "//" + arr[2];
ret.push(baseHostNameWithPort);
ret.push(listItem.FileRef);
}
else {
ret.push("return DispEx(this,event,'TRUE','FALSE','");
ret.push(listItem["File_x0020_Type.url"]);
ret.push("','");
ret.push(listItem["File_x0020_Type.progid"]);
ret.push("','");
ret.push(listSchema.DefaultItemOpen);
ret.push("','");
ret.push(listItem["HTML_x0020_File_x0020_Type.File_x0020_Type.mapcon"]);
ret.push("','");
ret.push(listItem["HTML_x0020_File_x0020_Type"]);
ret.push("','");
ret.push(listItem["serverurl.progid"]);
ret.push("','");
ret.push(Boolean(listItem["CheckoutUser"]) ? listItem["CheckoutUser"][0].id : '');
ret.push("','");
ret.push(listSchema.Userid);
ret.push("','");
ret.push(listSchema.ForceCheckout);
ret.push("','");
ret.push(listItem.IsCheckedoutToLocal);
ret.push("','");
ret.push(listItem.PermMask);
}
ret.push("')\">");
var fileRef = listItem["FileLeafRef"];
if (fileRef != null) {
var index = fileRef.lastIndexOf('.');
fileRef = index >= 0 ? fileRef.substring(0, index) : fileRef;
}
ret.push(fileRef);
ret.push("</a>");
PdfNewGif(listItem, listSchema, ret);
}
else {
/*ret.push("<nobr>");
ret.push(listItem["FileLeafRef"]);
ret.push("</nobr>");*/
}
return ret.join('');
}
Copy link to clipboard
Copied
Hey egalyk2093, I've used your code since its the most recent and everything is working as far as getting PDF's to open with the checkout option. I am running into one issue though, hoping you might be able to help. When I go to Site Settings and click Themes, I get the following error:
ReferenceError: 'spCommonSrc' is undefined |
function PdfNewGif(listItem, listSchema, ret) { if (listItem["Created_x0020_Date.ifnew"] == "1") { var spCommonsrc=GetThemedImageUrl("spcommon.png"); ret.push("<span class=\"ms-newdocument-iconouter\"><img class=\"ms-newdocument-icon\" src=\""); ret.push(spCommonSrc); ret.push("\" alt=\""); ret.push(Strings.STS.L_SPClientNew); ret.push("\" title=\""); ret.push(Strings.STS.L_SPClientNew); ret.push("\" /></span>"); } }
Copy link to clipboard
Copied
We implemented the pdffix.js on one SharePoint library. It is working well: it is now possible de 'Open and check out' a PDF file. However, we noticed that the editable forms created with PDF cannot be edited. We get the following error message from Acrobat: This document is hosted on a SharePoint/Office 365 server and is part of a production workflow. Save it on your computer to participate in the production Workflow. Would somebody be able to offer any help?
Copy link to clipboard
Copied
Just want to give a quick shoutout to Eric Hallgren for the fix. Here we are, five years later and this is still an issue in SharePoint 2016. Microsoft...
Thanks again!
Copy link to clipboard
Copied
I keep getting an error about the linkfile name
You cannot call a method on a null-valued expression.
At line:3 char:1
+ $field = $web.Fields.GetFieldByInternalName("LinkFilename")
Then I get this error
The property 'JSLink' cannot be found on this object. Verify that the property exists and can be set.
At line:4 char:1
+ $field.JSLink = "/_layouts/15/PdfFix.js"
Even though I confrim the file is there? Please help any one?
Copy link to clipboard
Copied
Hi shellsdog,
It is possible that you provided invalid library name. Library name and "name" from url may differ, so you can try to check library name by going to library settings.
Regards.
Copy link to clipboard
Copied
I have applied CU's Dec 2013 for SharePoint 2013 Server. PDF file opening in browser. I applied above mentioned PDFFIX.js script. But getting same result.
I need to show "Check Out and Open" PDF files in document libraries in Sharepoint 2013.
Copy link to clipboard
Copied
We ran across this issue updating from RTM to SP1 (SP 2013). I was able to implement the PDFFIX.js and have it working on a couple of site collections in our test environment.
I also have an active support ticket open with MS who sent me the link to this forum post and the following day (yesterday) sent me the exact instructions that are posted above. It seems in the time they have been doing "triage" in their product evaluation team, they still have no real fix for the issue. I am continuing to push for an actual fix/patch before implementing this in our production environment.
cs
Copy link to clipboard
Copied
Hi Chris,
I am still facing the error "There was an error opening this document. The filename, directory name, or volume label syntax is incorrect." even after replacing
ret.push("http://");
with:
ret.push(window.location.protocol + "//");
Please let me know if you have done any other changes to resolve this issue.
Thanks,
Varun
Copy link to clipboard
Copied
I have no idea if this helps, as I am not tech savvy. But I did have this exact message today and have resolved it. Here was my issue and resolution.
I couldn't open a pdf document I had just saved in a folder I created on our company drive ( just like I always do). However, I could view/open that same pdf if I opened it directly from the email I received it in (I use Microsoft Outlook). Also, I could still view/open other pdf's previously saved throughout my other computer files. Just not the newest pdf that I had saved.
I figured out that where I was trying to save the pdf had a file path that was too long (for whatever reason. - maybe this is exactly what you guys are trying to fix... I don't really know). In other words it was saved in a folder that was 8 folders away (deep) from my computer drive. For some reason that seams to be the cutoff length for my adobe. Anyway, I simply saved the pdf one folder up and it works perfect.
Hope this helps in some way!
Marie
Copy link to clipboard
Copied
If the fix provided above doesn't help, try it in addition to changing IE Options -> Security -> Select appropriate zone -> Custom Level ->
and set Automatic propmpting for ActiveX controls to Enabled.
Regards.