Hi,
I would like to know if it is possible to prevent user from copying selected text into the PDF?
Thanks for your help.
S.
You can disable text layer rendering by setting e.g., https://github.com/mozilla/pdf.js/blob/master/web/default_preferences.json#L12 to true
.
Thank you @timvandermeij. It is working.
I cannot find the option to unactivate print and download functions.
Is there a clean way to do it or do I need to comment out the HTML code?
Thanks for your help.
There is no option for that in the default viewer, so you'll have to implement that yourself.
@timvandermeij thank you for your answer.
@timvandermeij disabling text layer rendering is a good workaround to prevent from copying text but unfortunately the search function loses the highlight feature. Is there an other workaround where I can prevent from copying selected text but still able to highlight searchs into PDF?
Thanks for your help.
S.
No, the search function directly depends on the text layer.
See if https://developer.mozilla.org/en-US/docs/Web/Events/copy will help
Why not disable selection of text layer from CSS?
.textLayer {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Safari */
-khtml-user-select: none; /* Konqueror HTML */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently
supported by Chrome and Opera */
}
of course, it's not bulletproof, but the web isn't in the end, is it? ;)
And keeps search working
Thanks @sielay, it is what I have done.
for the question: I cannot find the option to unactivate print and download functions.
you can try this
<script type="text/javascript">
document.getElementById("secondaryOpenFile").style.display = "none";
document.getElementById("openFile").style.display = "none";
document.getElementById("secondaryPrint").style.display = "none";
document.getElementById("print").style.display = "none";
document.getElementById("secondaryDownload").style.display = "none";
document.getElementById("download").style.display = "none";
</script>
in your viewer.html file
Most helpful comment
Why not disable selection of text layer from CSS?
of course, it's not bulletproof, but the web isn't in the end, is it? ;)
And keeps search working