Hide/Disable download button on Chrome PDF Viewer

24,720

Solution 1

You can do it by using embed tag

by making #toolbar=0 you will be able to hide the download and print button.

Solution 2

If it's only for not so tech-saavy users, you can disable download in the chrome pdf viewer by generating one-time usable unique urls eg. with a query string parameter that is stored on server and allowed to be used only once. The download button does download a second time and will fail in this case. This is however an implementation detail in the chrome pdf viewer that might change. If the user does not have a pdf viewer in the browser or it is disabled, the file will simply download by default.

You might want to try pdf.js, that will render and not download in any browser, but tech-saavy users will still be able to get the document. It is probably also less performant than the chrome pdf viewer.

If you turn the content into images, users can still take the batch of images and combine them into a pdf, however in this case the text is harder to recover, but still possible with OCR.

If you want to make it harder to copy the content or just detect it, you could also use watermarks in your downloaded images or incorporate steganography to identify the user who made the copy based on the released file found in the wild. Be aware that watermarks can always be removed, usually very easily from PDF files and it is a bit harder but still possible to remove from images. Carefully designed hidden identifiers (steganography) can also be removed but it has to be found first and usually users don't look when a document is not obviously stamped.

Solution 3

Since you are delivering pdf file directly into the browser, displayed using Adobe Reader ActiveX, how can it be possible to prevent file download, since the files are displayed after downloaded into your temp directory?

So it is not possible using ANY JavaScript library.

The only way to secure your master PDF files is by creating Images for each page and present those to the user on the web via your own interface (html, flash etc).

You may use ImageMagick along with GhostScript for this.

Share:
24,720
Admin
Author by

Admin

Updated on January 11, 2022

Comments

  • Admin
    Admin over 2 years

    I'm looking for a way to hide or disable the download button that appears in the Chrome PDF viewer. I have disabled the print button using the protection script of fpdf(http://www.fpdf.org/en/script/script37.php), but it doesn't help with the download button. The PDF is currently being opened in a new window via :

    window.open(URL, "", "resizable=yes, scrollbars=yes, titlebar=yes, width=1024, height=900, top=10, left=10");

    I realize this won't stop any somewhat informed user from saving/printing the PDF, but the client is insisting on this "security measure".

    If I inspect the element using Dev Tools and add display: none it does what I want, but I'm not sure how to add that by default in the new window that opens.

  • Admin
    Admin over 7 years
    Hi, I don't need to actually prevent downloading the file, as that is not possible since like you said it is in the temp file system. I just want to hide the toolbar in the chrome PDF viewer to satisfy an arbitrary client request. If I inspect the element using developer tools and then add display: none it does the trick, but I'm not sure how to set that by default.
  • Patrick Mlr
    Patrick Mlr over 7 years
    I don't think that this is possible.
  • Ankur Sahu
    Ankur Sahu almost 7 years
    You should actually try pdf.js
  • Max Williams
    Max Williams almost 5 years
    This worked for me - i;m using an object tag, not an embed, but adding #toolbar=0 to the end of the file uri that goes into the data attribute worked. Thanks!
  • Manal Liaquat
    Manal Liaquat over 2 years
    can you please share an example link
  • varun sharma
    varun sharma about 2 years
    I was thinking of a solution like if pdf can be encrypted and then a decrypted pdf is opened via pdf.js. The js also is to be made tempered proof using online tools so it can make very difficult for someone to understand it.