none
disable print,download,copy and select all buttons progrmatically using jquery or javascript on iframe,(iframe is on popup bootstrap) RRS feed

  • Question

  • Hi,

    I have designed webpart to show file name on table where user click so respective file open in browser . my UI

    Code using is window.open(fileurl) 

    Problem:

    using browser user can download, print and copy document to local machine 

    Solution Required

    I need to  allow user to just view file nothing else


    • Edited by qasimidl Thursday, July 18, 2019 7:32 PM
    Wednesday, July 17, 2019 8:03 AM

All replies

  • Hi,

    I have uploaded files (pdf and doc ) in document library programmatically using Rest APi.

    Problem:

    I want to allow user to view only these files without downloading and also unable to print.

    How can I do this?

    Thanks

    Monday, July 8, 2019 10:59 AM
  • Hi Qasimidl,

    To prevent people from downloading files you would need to prevent them from reading the file.  If they can read/view it then they can download it. The only way to allow users to read but not edit or print a file would be to implement Windows Rights Management. You can read more about that from below article:  

    https://support.office.com/en-us/article/apply-information-rights-management-to-a-list-or-library-3bdb5c4e-94fc-4741-b02f-4e7cc3c54aa1

    https://docs.microsoft.com/en-us/previous-versions/office/developer/sharepoint-2010/ms458245(v=office.14)

    Thanks & Regards,


    sharath aluri

    Monday, July 8, 2019 1:30 PM
  • Hi Qasimidl,

    You can not restrict user to download or print the document through permission without configuring IRM. If user is able to view the document then also he/she can save the document in his/her desktop or print through browser.

    So you will need to configure IRM and provide the permission accordingly. See my reply in below thread:

    https://social.msdn.microsoft.com/Forums/office/en-US/03f2a503-1042-447e-8f27-33ed8887a83d/how-to-restrict-document-download-in-sharepoint-2010?forum=sharepointgeneralprevious

    If you remove the "Name" column from the views of the document library thent he Url link of the document will no longer appear and users will not be able to open and print the document. You would then have to disable or hide the "Edit Document" ribbon button possibly with jQuery or javascript.

    https://social.msdn.microsoft.com/Forums/office/en-US/c4744e76-cf07-4c34-99f1-e3f512071efb/showhide-sharepoint-ribbon-buttons?forum=sharepointdevelopmentlegacy

    https://blogs.ibs.com/2014/01/10/post-codemash-2014/


    sharath aluri


    Wednesday, July 17, 2019 2:56 PM
  • its custom visual webpart,showing data on table, if I remove filename so how can user has link to view the file

    Thursday, July 18, 2019 5:55 AM
  • Hi,

    You can use <embed> or <iframe> tag to display Pdf file content without print/download/copy, please check the same requirement question below for a reference:

    How do I embed a PDF file in HTML without a download, save and print option?

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Thursday, July 18, 2019 8:17 AM
  • already used this, its not working

    I am using iframe,successfully opened file on iframe,just need to do below things

    1) disable right click so user cannot saveAs and print option

    2) disable copy and pring screen (ctrl+c )


    Thursday, July 18, 2019 9:40 AM
  • Hi,

    You can use Jquery code to disable right click and ctrl+C in your page:

    Disable mouse right click, cut, copy and paste using jQuery

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Thursday, July 18, 2019 9:54 AM
  • I have used this with iframe ID , not working as I don't have "body" and html  tag on webpart(visual webpart). I am place iframe in popup (bootstrap).

    I have placed this text on body of master page so it works except iframe (not allowed right click)

            <script type="text/javascript">//<![CDATA[
    $(document).ready(function(){
        $(this).on('contextmenu', function(e){
            e.preventDefault();
        });
    });

    but after opening pdf right click is working

    Kindly guide plz






    • Edited by qasimidl Thursday, July 18, 2019 9:22 PM
    Thursday, July 18, 2019 7:14 PM
  • Hi,

    Try build the iframe like this, replace src with yours, not remove the append toolbar and navpanes, style.

    And create a div set oncontextmenu return false to host the iframe:

    <div id="test" oncontextmenu="return false"> 
        <iframe src="../mydoc1/sample.pdf#toolbar=0&navpanes=0" style="pointer-events:none;"   width="1000" height="1000"></iframe>
    </div>
    

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Friday, July 19, 2019 9:54 AM
  • not working when I right click on pdf it does not work, outside pdf it works
    • Edited by qasimidl Friday, July 19, 2019 8:00 PM
    Friday, July 19, 2019 7:26 PM
  • is any one can help me out on this 
    Monday, July 22, 2019 9:00 AM
  • not working when I right click on pdf it does not work, outside pdf it works

    Hi,

    I tested in Chrome, where did you test ?

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, July 22, 2019 9:48 AM
  • ie 11
    Monday, July 22, 2019 10:01 AM
  • IE11 need third party PDF Software add on support to display PDF in browser,  for example: Adobe, which one do you use ?

    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.



    Monday, July 22, 2019 10:29 AM
  • how can I check this
    Monday, July 22, 2019 10:45 AM
  • Check from IE11 Manage Add-on, most probably, the right menu for Pdf in IE11 is coming from this third party tool:


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Monday, July 22, 2019 10:54 AM
  • see the below image

    find no pdf reader

    Monday, July 22, 2019 11:14 AM
  • Need help on this,waiting
    Tuesday, July 23, 2019 5:56 AM
  • Hi,

    Please provide a capture about the right menu of pdf iframe for us to check.

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    SharePoint Server 2019 has been released, you can click here to download it.
    Click here to learn new features. Visit the dedicated forum to share, explore and talk to experts about SharePoint Server 2019.

    Tuesday, July 23, 2019 7:48 AM
  • my code

    <div class="modal fade" id="div_modshowfile" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content" style="width: 900px"  onload="disableContextMenu();">
                <div class="modal-header">
                    <h5 class="modal-title" id="hid_modshowfile"></h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true" id="span_modshowfile">&times;</span>
                    </button>
                </div>
                <div class="modal-body"  onload="disableContextMenu();">
                     <iframe src="#" style="pointer-events:none;" id="frmpdf" width="800" height="500">
                        </iframe>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>

                </div>
            </div>
        </div>
        <%--these fields used when document
        --%>
    </div>

      <a href="#" id="lnkview_" onclick="viewDoc()"</a>

    function viewDoc()

    {

    var url="http://abc-12:44001/DocDepart/test-15-32-37.pdf";

       var links ='url' "#embedded=true&toolbar=0&navpanes=0 style=pointer-events:none;width=1000;height=1000";
                    document.getElementById("frmpdf").src = links;
                       //jQuery('frmpdf').attr('src', links);
                  
                    $('#div_modshowfile').modal('show');

    }

    Wednesday, July 24, 2019 10:02 AM
  • is any one help me  on this 
    Thursday, July 25, 2019 10:56 AM
  • still waiting for reponse..
    Friday, July 26, 2019 1:06 PM
  • is any one can help me out this
    Monday, July 29, 2019 7:11 AM