Hide/Disable download button on Chrome PDF Viewer

蓝咒 提交于 2019-12-19 11:35:58

问题


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.


回答1:


You can do it by using embed tag

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




回答2:


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.

You may go through veryinteractivepeople

Hope this helps. (:




回答3:


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.



来源:https://stackoverflow.com/questions/39505505/hide-disable-download-button-on-chrome-pdf-viewer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!