How to make PDF without downloading using pdf.js

I found the pdf.js project, which is very useful. However, I cannot figure out how to remove the Download option.

+6
source share
5 answers

Here are the steps:

  • Add jQuery library to the shared folder.
  • Include jQuery library in viewer.html file
  • Add this to the header section:

    <script> $(function(){ $('#download').hide(); }); </script> 

Done!

+5
source

Simple button removal breaks pdf.js. You need to add a β€œhidden” class to them ( https://github.com/mozilla/pdf.js/issues/2611 )

+12
source

just add this to viewer.css

 .download { display:none !important; } .print { display:none !important; } 
+3
source

Change the source. Line 85 web /viewer.html.

https://github.com/andreasgal/pdf.js/blob/master/web/viewer.html#L85

Just remove the button.

  <button id="download" title="Download" onclick="PDFView.download();" oncontextmenu="return false;"> <img src="images/download.svg" align="top" height="16"/> Download </button> 

This will not completely stop experienced and impatient users from downloading it. You will never stop it. But this is enough to raise the bar enough for the curious.

+2
source

The easiest way is to add the hidden class to a specific button on the toolbar (the download button in this case)

PDF.JS has a hidden class included by default in its CSS file. So just add the hidden class to the button with the identifier download and secondaryDownload

0
source

Source: https://habr.com/ru/post/949016/


All Articles