PHP to view PDF on web page and disable user to download

后端 未结 6 2196
别跟我提以往
别跟我提以往 2020-12-05 21:53

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

相关标签:
6条回答
  • 2020-12-05 22:15

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

    You could output the pdf using <object> or <iframe>, 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 <div>!!!!

    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.

    0 讨论(0)
  • 2020-12-05 22:16

    try this

    <embed src="http://URL_TO_PDF.com/pdf.pdf#toolbar=0&navpanes=0&scrollbar=0" width="500" height="500">
    
    0 讨论(0)
  • 2020-12-05 22:17

    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 :

     <iframe src="http://docs.google.com/gview?url=http://www.tutorialspoint.com/php/php_tutorial.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0">
    </iframe>
    

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

    0 讨论(0)
  • 2020-12-05 22:21

    Method 01

    Implementing that useing Google books

    <iframe frameborder="0" scrolling="no" style="border:0px" src="https://books.google.com.kh/books?id=e5MkzETNcsgC&lpg=PP1&dq=typography&pg=PA11&output=embed" width="500" height=500>
    </iframe>
    

    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

    0 讨论(0)
  • 2020-12-05 22:24

    Try this one:

    <iframe  src="test1.pdf" scrolling="no" frameborder="0" height="100%" width="100%" style="position:absolute; clip:rect (190px,1100px,800px,250px);">
    

    0 讨论(0)
  • 2020-12-05 22:30

    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.

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