user2857294
user2857294

Reputation: 29

How to prevent downloading PDF file when displaying on web pages?

How to prevent downloading PDF file when displaying on web pages?

I tried the content disposition inline but it didn't work.

How can i do this ?

Upvotes: 0

Views: 1163

Answers (2)

KMP
KMP

Reputation: 1

After weeks of searching, trying tons of plugins, viewers, embedders, etc., I finally came up with a solution. It's a combination of a paid plugin and a free plugin. The free plugin I'm using is "Prevent Files / Folders Access" https://wordpress.org/plugins/prevent-file-access/ which protects the url of the PDF if somebody manages to get it by viewing page source. And I purchased PDF Poster: https://wordpress.org/plugins/pdf-poster/ However, I'm waiting for this plugin developer to answer my request for a bit of CSS to add to it to enable vertical scrolling and the hand tool both by default. I would have preferred a free solution, but this is the best I could come up with, and I needed to move ahead and get my hundreds of embeds done. I hope this is helpful to someone else out there.

Upvotes: 0

Uchit Shrestha
Uchit Shrestha

Reputation: 547

One option is to render the PDF to JPEG or some other image format and only serve the rendered images to the user. Some of the PDF libraries allow you to render PDF's to other file formats.

Another option may be to send/redirect the PDF through to an online PDF viewing app in the same way Google does with attachments in GMail. That way the user sees a JPEG of the PDF and cannot download the PDF.

Upvotes: 4

Related Questions