Embed PDF on a webpage and prevent download

后端 未结 7 730
耶瑟儿~
耶瑟儿~ 2021-02-06 06:12

Is there a way to embed a PDF document on a webpage and at the same time disabling download? If possible I would prefer an html5/css3 solution. If no other way is possible I\'d

相关标签:
7条回答
  • 2021-02-06 06:29

    Short answer is, it can't be done. The only way to view a PDF document without any kind of conversion is via the adobe PDF plugin, and that invariably allows the document to be saved. On top of that, it's trivial to use various tools to get the url of the PDF and download it from there.

    If you want to avoid sending the actual PDF document, you could create a server-side script that converts the PDF document to a series of PNG or JPG images behind the scenes. You can do this with ghostscript for example.

    But then, the actual content of the document still reaches the user, only in a different format. If this is not satisfactory for you, there are various techniques you can use to prevent most users from saving the images, but these are easily circumvented by a sufficiently technically savvy user.

    0 讨论(0)
  • 2021-02-06 06:31

    You can use SlideShare, you can set a read password, prevent users from downloading in the settings, and even create a secret link so only users with it can open it. I am sure there are ways to circumvent this, but at least it's not immediate.

    0 讨论(0)
  • 2021-02-06 06:35

    Actually, it is possible, you can adjust in your Google Drive option "Prevent viewers from downloading" Then set PDF file public, so everyone can view PDF in Viewer, but none can download it. I hope, that this will help for some.

    0 讨论(0)
  • 2021-02-06 06:36

    Yes. Yes there is:

    <div id="pdf">
        <object width="100%" height="650" type="application/pdf" data="[ImageURLHere]#zoom=85&scrollbar=0&toolbar=0&navpanes=0" id="pdf_content" style="pointer-events: none;">
            <p>Insert your error message here, if the PDF cannot be displayed.</p>
        </object>
    </div>
    

    The pointer-events: none styling will also prevent users from right-clicking the PDF and downloading.

    0 讨论(0)
  • 2017 Note: this feature has moved locations and the implementation has changed since it was originally answered.


    Google Viewer offers a solution.

    Use the iframe it generates for you.

    0 讨论(0)
  • 2021-02-06 06:48

    You can download the PDF.js and modify these 2 files: viewer.html and viewer.js, remove/modify the corresponding buttons/actions in order to disable downloading/printing, and you can furtherly disable right click menu items.

    0 讨论(0)
提交回复
热议问题