ХЫтрый ツ
ХЫтрый ツ

Reputation: 53

How to remove the functionality of printing in the file viewer.js on Prebuilt Pdfjs from mozilla?

How to remove the functionality of printing in the file viewer.js on Prebuilt Pdfjs from mozilla?

In this file, too much code(~10K) and I can not understand, how there it is implemented. Help please, at least explain how it is in this file is implemented. Advance thanks.

Upvotes: 0

Views: 1798

Answers (1)

Koushik Shom Choudhury
Koushik Shom Choudhury

Reputation: 856

Since, removing or commenting out the HTML element throws error, remove or comment the following lines from viewer.js to remove Print, Download, Open features (you can also remove any one of these since you only need to remove print):

eventBus.on('beforeprint', _boundEvents.beforePrint);
eventBus.on('afterprint', _boundEvents.afterPrint);
eventBus.on('openfile', webViewerOpenFile);
eventBus.on('print', webViewerPrint);
eventBus.on('download', webViewerDownload);

And as a precuation I would suggest disabling the document property request by disabling the concerned event too, so remove or comment

eventBus.on('documentproperties', webViewerDocumentProperties);

For being on the safe side, also remove or comment the eventBus.off for each of the events above. For example:

eventBus.off('print', webViewerPrint);

I couldn't tell you the line numbers of these codes exactly since my viewer.js has been modified beyond restoration to it's original form.

Finally, add hidden attribute to the HTML elements or figure out some other way to hide it, but whatever you do, do not remove or comment the HTML elements.

Upvotes: 2

Related Questions