Copy link to clipboard
Copied
Is There any way to disable text copy in adobe view sdk, I have a website in which i provide university study materail to students but the problem is coming that many other website copy the content of my uploaded notes and upload on there website so is there any way by which i can disable copying text option so my notes content remain safe. please tell if there is a way.
Hi Himanshu,
Although I am not able to see any enableTextSelection API invocation.
You can write this API right after your page adjust.
// Go to the page. Page numbers are 1 based.
apis.gotoLocation(parseInt(page));
apis.enableTextSelection(false);
Let me know if it works for you.
Copy link to clipboard
Copied
Hi Himanshu,
Thanks for choosing PDF Embed API. For your use case, you can disable the text selection using enableTextSelection API mentioned under Viewer API section in our public documentation https://www.adobe.io/apis/documentcloud/dcsdk/docs.html?view=view
Copy link to clipboard
Copied
There are two methods. You can do it via code in the Embed API configuration as is described already in this thread however, that will only prevent text selection while the file is being viewed. If you allow the file to be downloaded, other PDF viewers can be used to select and copy text. The other method is to set a permissions password on the PDF. This method is persistent in the PDF and will be respected by most PDF viewers including Embed API. You can use Acrobat to set the password. See image below.
Copy link to clipboard
Copied
I think first method wiil work for me i think using using enableTextSelection API but the problem is that iam also using code to jump to specific page and when iam applying enableText Api it is not working please look my code
and tell me where to put api code.
<div id="embeddedView"></div>
<script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
<script type="text/javascript">
// Add ?page=4 to the end of the URL
const urlToPDF =
"https://documentcloud.adobe.com/view-sdk-demo/PDFs/Bodea Brochure.pdf";
const clientId = "7ee820c71c32474497c3c94c29ba3553";
const viewerOptions = {
embedMode: "FULL_WINDOW",
defaultViewMode: "FIT_WINDOW",
showDownloadPDF: false,
showPrintPDF: false,
showLeftHandPanel: true,
showAnnotationTools: false
};
function fetchPDF(urlToPDF) {
return new Promise((resolve) => {
fetch(urlToPDF)
.then((resolve) => resolve.blob())
.then((blob) => {
resolve(blob.arrayBuffer());
});
});
}
var page={{$pageNumber}};
function goToPage(previewFilePromise, pageNum) {
previewFilePromise.then((adobeViewer) => {
adobeViewer.getAPIs().then((apis) => {
// Go to the page. Page numbers are 1 based.
apis.gotoLocation(parseInt(page));
});
});
}
function processEvent(event, previewFilePromise) {
if (event.type == "PDF_VIEWER_OPEN") {
// Get the page parameter from the URL
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const pageNum = urlParams.get("page");
// Go to the page number specified in the URL
goToPage(previewFilePromise, pageNum);
}
}
document.addEventListener("adobe_dc_view_sdk.ready", function () {
// Create embedded view
var adobeDCView = new AdobeDC.View({
clientId: clientId,
divId: "embeddedView"
});
// Show the file
var previewFilePromise = adobeDCView.previewFile(
{
content: { promise: fetchPDF(urlToPDF) },
metaData: { fileName: urlToPDF.split("/").slice(-1)[0] }
},
viewerOptions
);
// create object to set events that we want to listen for
var eventOptions = {
listenOn: [AdobeDC.View.Enum.Events.PDF_VIEWER_OPEN],
enableFilePreviewEvents: true
};
// register the event callback
adobeDCView.registerCallback(
AdobeDC.View.Enum.CallbackType.EVENT_LISTENER,
function (event) {
processEvent(event, previewFilePromise);
},
eventOptions
);
});
// Helper Function: Add arrayBuffer if necessary i.e. Safari
(function () {
if (Blob.arrayBuffer != "function") {
Blob.prototype.arrayBuffer = myArrayBuffer;
}
function myArrayBuffer() {
return new Promise((resolve) => {
let fileReader = new FileReader();
fileReader.onload = () => {
resolve(fileReader.result);
};
fileReader.readAsArrayBuffer(this);
});
}
})();
</script>
Copy link to clipboard
Copied
Hi Himanshu,
Although I am not able to see any enableTextSelection API invocation.
You can write this API right after your page adjust.
// Go to the page. Page numbers are 1 based.
apis.gotoLocation(parseInt(page));
apis.enableTextSelection(false);
Let me know if it works for you.
Copy link to clipboard
Copied
Yeah it worked thanks for your response iam very thankful to your fast response and help.
Copy link to clipboard
Copied
can you send me the function you have used to prevent user from copying .