How to disable pdf download in browser using php

I'm going to write a site that lets users to view pdf files but I don't want them to save the files to their own hard drive due to the copy right law. I'm researching how to view it by using PHP, but I have no idea how to disable user not to download the files.

Actually, I want to use JavaScript to disable this action, but I get suggestions from other people not to do so because it's annoying to user.

So any suggestion or help would be very much appreciated.

asked May 4, 2012 at 2:34

Tepken VannkornTepken Vannkorn

9,56014 gold badges59 silver badges85 bronze badges

2

USE CSS opacity: 1.0 with a
positioned over your content...

You could output the pdf using or , then place a with absolute position and use z-index to cover your pdf. Use the css opacity: 1.0.

Now when users try to click or copy, they get nothing because they are really clicking on a blank

!!!!

Its a hack, but it works! The user will be able to read the content, they could take a screen shot, but they won't be able to actually copy the text and paste it anywhere.

answered Apr 2, 2017 at 15:40

Method 01

Implementing that useing Google books



In above image it shows Embed that will be the code. And Download or Print option is not available on this. Google dosc can prevent download but its allow to Save to Drive option. Then in drive i can download it. But Google books not allow any of that.

in view

Method 02

Using Google Drive

Right click on pdf and goto Share[below image]

Then go to Advanced option in left bottom

Tick Both check boxes. After copy embed link and paste it to your src. No download and Save drive option is not allowed

Note: Method 01 and Method 02 is Tested

answered Aug 11, 2015 at 6:40

Abdulla NilamAbdulla Nilam

32.8k16 gold badges61 silver badges80 bronze badges

You can't prevent your visitors from downloading, copying or scrapping anything you're outputting to their browsers. If they can view it they can always screenshot it. Which brings in the optimal solution to your problem: Simply offer image copies of your documents instead of actual PDF files. You can convert / mass convert PDF files to JPEG easily with Photoshop.

answered May 4, 2012 at 2:45

VarolVarol

1,7181 gold badge21 silver badges29 bronze badges

2

I hope I am not very late to reply. But here's is something you can do to prevent the users. Use iFrame to display your PDF and make sure that you are displaying using Google. I used the following code :

 

Here you can simply change the url=//www.tutorialspoint.com/php/php_tutorial.pdf and replace it by your own URL where you kept your PDF.

answered Sep 11, 2014 at 7:11

JiteenJiteen

4292 gold badges6 silver badges23 bronze badges

1

Try this one:


answered Nov 22, 2017 at 18:41

try this


answered Oct 30, 2018 at 4:19

1

How do I stop PDF from downloading in my browser?

What to Know.
In the Chrome browser, select the three vertical dots in the upper-right corner..
Choose Settings > Advanced > Privacy and security. Select Site Settings > PDF documents..
Use the toggle switch next to Download PDF files instead of automatically opening them in Chrome to turn the feature on and off..

How do I open PDF in browser instead of download in PHP?

At the bottom, click Advanced. Under "Privacy and security," click Content settings. Near the bottom, click PDF documents. Turn off Download PDF files instead of automatically opening them in Chrome.

How do I disable download view in PDF?

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

How do I turn off save as PDF in HTML?

Information.
In Adobe navigate to Edit > Preferences > General..
Locate the options for "Show online storage when opening files" and "Show online storage when saving files"..
Disable both options as desired..

Chủ Đề