Quantcast
Channel: Adobe Community: Message List - Enterprise Deployment (Acrobat and Reader)
Viewing all articles
Browse latest Browse all 6853

Re: Sharepoint 2013 PDF check out and open option

$
0
0

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***********************


Viewing all articles
Browse latest Browse all 6853

Trending Articles