Disable text selection to avoid copy text in web viewer

771 views
Skip to first unread message

gopalak...@contentraven.net

unread,
Aug 13, 2018, 1:36:53 PM8/13/18
to PDFTron WebViewer
Hi,

I am using Pdftron webviewer v3.2.0. I need to Disable text selection in the web viewer to avoid copy text in web viewer. Can you please help to provide suitable solution for this.

Also I want to disable the Copy, Highlight, Strikeout, Underline, Squiggly menu options after selecting the text in the web viewer.

Looking forward to your reply.

Thanks & Regards,
Gopalakrishnan.S

Matt Parizeau

unread,
Aug 14, 2018, 5:52:56 PM8/14/18
to PDFTron WebViewer
Hi Gopalakrishnan,

You can disable text selection using the following code in your config file (https://www.pdftron.com/api/web/Tools.Tool.html#Tool__anchor):

Tools.Tool.ENABLE_TEXT_SELECTION = false;

Once this is disabled you won't be able to select text on the document and the menu with "Copy" and text annotations won't appear.

Matt Parizeau
Software Developer
PDFTron Systems Inc.

gopalak...@contentraven.net

unread,
Aug 16, 2018, 1:25:38 PM8/16/18
to PDFTron WebViewer
Hi Matt,

Thanks for your response. I tried to call the below code in "DocumentLoaded" event and it is not working. 
Below is the code which I called in "DocumentLoaded" event.

var annotManager = readerControl.docViewer.getAnnotationManager();
annotManager.Tools.Tool.ENABLE_TEXT_SELECTION=false;

It is throwing the below error.

Uncaught (in promise) Error: Error loading document: TypeError: Cannot read property 'Tool' of undefined
    at Object.NH.onError.a.onError (CoreControls.js:1075)
    at CoreControls.js:1082

Can you please provide correct code sample in order to achieve this?

Looking forward to your reply.

Thanks & Regards,
Gopalakrishnan.S

Matt Parizeau

unread,
Aug 16, 2018, 6:18:57 PM8/16/18
to PDFTron WebViewer
Hi Gopalakrishnan,

You don't need to modify the code that I provided at all, you can put it directly in your config file and it doesn't need to be in the documentLoaded event. The tools namespace is defined on the window and not on the AnnotationManager.
Tools.Tool.ENABLE_TEXT_SELECTION = false;

Matt Parizeau
Software Developer
PDFTron Systems Inc.
Reply all
Reply to author
Forward
0 new messages