Reputation: 11
I'm very according with PDF.JS but now I need some help. I load (view) the pdf file online with PDF.JS but I need that don't be downloaded. I managed to remove the download button/function from HTML but now I need to know how to prevent direct access to the (without impeding PDF.JS to read it). Any ideas? :) Thanks
Upvotes: 1
Views: 2342
Reputation: 91
You can block direct access to the file by .htaccess:
# Block direct access to PDF
RewriteCond %{REQUEST_URI} \.pdf$ [NC]
RewriteCond %{HTTP_REFERER} !YOURDOMAIN\.COM [NC]
RewriteRule .* http://YOURDOMAIN.COM/forbidden
You need also to prevent caching of pdf files
Upvotes: 3
Reputation: 1361
You can't. You can download any content that goes through the browser, with the appropriate tool, even if you use javascript to load it. For example the "DownloadHelper" addon for Firefox will capture anything from youtube videos to simple images that the script downloads dynamically.
The only way to prevent it is to use 3rd party addons that can download content without the browser. Adobe Flash's RTMP protocol is one example. It circumvents the browser so it's invisible for the other addons.
But I don't suppose you'd want to write a PDF viewer in flash just so no one could download it.
Upvotes: 0