Asked by:
disable print,download,copy and select all buttons progrmatically using jquery or javascript on iframe,(iframe is on popup bootstrap)

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
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
- Merged by Wendy DZMicrosoft contingent staff, Moderator Friday, July 19, 2019 5:13 AM duplicated
-
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:
sharath aluri
- Proposed as answer by Jerry ZyMicrosoft contingent staff Tuesday, July 9, 2019 9:48 AM
-
check Information Rights Management (IRM). E.g. Restrict download and print option for SharePoint Online document library.
Blog - http://sadomovalex.blogspot.com
Dynamic CAML queries via C# - https://github.com/sadomovalex/camlex -
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: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://blogs.ibs.com/2014/01/10/post-codemash-2014/
sharath aluri
- Edited by Sharath Aluri (MCP, MCSE, MCSA) Wednesday, July 17, 2019 2:57 PM
-
-
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. -
-
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
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. -
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
-
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. -
-
-
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. -
-
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.
- Edited by Jerry ZyMicrosoft contingent staff Monday, July 22, 2019 10:30 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. -
-
-
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. -
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">×</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');}
-
-
-