Solved

PHP PDF Viewer solution

Posted on 2004-09-02
17
10,332 Views
Last Modified: 2012-08-13
Here's what I need to do.

My php application needs to pass a PDF off to a page, which will let the user view the pdf, zoom and pan.. but not let them actually have access to the pdf itself. (if they want that they have to buy it). Nor should they be able to print it.

I am assuming i will need to get a JAVA or FLASH 3rd party viewer to do this. It (the 3rd party app) must also be able to be resold as part of a larger package.

I am not against programming something to do this myself, but I don't now of any options to do this in pure php.

Please let me know of any options. It must be fast. Once it loads up the pdf, should be very quick in pan and zooming.

Dan
0
Comment
Question by:micamedia
  • 8
  • 7
  • 2
17 Comments
 
LVL 36

Expert Comment

by:Zyloch
ID: 11969834
Hi

Er... what if the user uses Print Screen and captures your screen? What if the user goes to File Print? Not much you can do there. I'm just warning you what many other people will warn you of, so if you still want to do this, you can tell us so.

Regards,
Zyloch
0
 
LVL 25

Expert Comment

by:Squinky
ID: 11972805
You can't do directly what you're asking. It's not possible to view a PDF without giving it to the client., nor is PHP much use because it's only server-side anyway.

PDF itself can be securely encrypted and protected against opening, printing and copy/paste, and it's well supported by web plugins such as Adobe's and Schubert IT's OS X plugin, however, neither will work at all unless the PDF can be downloaded in the first place. Not much you can do about screen shots, but then they don't capture much of what's in a PDF anyway (e.g. hot links).

The only way to prevent a user displaying an unprotected PDF is not to give it to them, which translates to, only show previews, perhaps a sample chapter (as an unprotected PDF, which will allow everything you're asking for) or use screen shots.

You can set security and assign user names and passwords dynamically using something like PDFLib from PHP.

Neither Flash nor Java will be much help either as they will suffer exactly the same issues.
0
 
LVL 1

Author Comment

by:micamedia
ID: 11973246
I've seen pdf views like i need in other document collaberation packages.

As for the screen shots i don't mind about that. I just want people to be able to view the pdf without having to have acrobar reader.

I know that any client side browser plug in will have to download the pdf to view it. but it won't let the user save it like the regular adobe reader would.

There has to be a way.
0
 
LVL 25

Expert Comment

by:Squinky
ID: 11974284
If the browser can request a PDF in order to view it, then the user will be able to save it, and there's nothing you can do about it - it's nothing to do with plugins at all - you could easily extract the URL and pass it to e.g. CURL, trivially bypassing any plugin restrictions, or just "save link as..." instead of opening the document directly. You should instead be concentrating on either making what they view something other than a PDF (with Flash (look at flashpaper) or Java, as you suggest), or instead give them a PDF of cut-down content.

I don't know of any common plug-in PDF viewers other than Adobe's and Schubert IT's. I guess there may be a Java applet, but I suspect that Java availability on Windows is worse than Acrobat reader. Whatever, you're still stuck with the basic problem - you can't view PDF on a web page without a PDF plugin. You can easily view something other than a PDF as a kind of simulation, but then it's not viewing a PDF (duh!).

> I've seen pdf views like i need in other document collaberation packages.

So how did they do it without using PDF?
0
 
LVL 1

Author Comment

by:micamedia
ID: 11974597
well my client told me this.. told me it was a flash viewer. So maybe i'm looking for a flash viewer?
0
 
LVL 1

Author Comment

by:micamedia
ID: 11974621
Ok so what about the flash solutions. I'm open to that.
0
 
LVL 1

Author Comment

by:micamedia
ID: 11974697
Ok.. i just increased the points to 500.. that should help :)

Now.. i just took a look at flash paper.. it's pefect. Exactly what i want in a document viewer online.

Now the problem become.. how do i take the pdf files that people upload and programatically covert them into something flash viewer can display?

0
 
LVL 25

Expert Comment

by:Squinky
ID: 11976551
Bear in mind that flashpaper offers you no protection. People can still print the doc at fair quality, and the swf can be grabbed and redistributed just as an unprotected PDF can. If you do a wholesale conversion of a PDF into flashpaper, you're effectively giving the PDF away, which I gathered is not what you're intending! Flashpaper is only available from macromedia, and it's only available as a windows app. It's not scriptable or batchable, so i suspect your chances of automating it as a web back end are slim. So, unless you're willing to convert your docs manually, I think you may find it's a dead end.
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 36

Expert Comment

by:Zyloch
ID: 11976799
Screen capture is the worst of the worst :) And the biggest problem is that you don't have to be extremely computer literate to do it--even if it was the hardest thing in the world, the people that can do it will spread it all over the net anyways if it's worth anything. Why show it to them anyways? They can just keep coming back to their computer or what if they have a laptop??? lol

Just some thoughts to ponder.
0
 
LVL 1

Author Comment

by:micamedia
ID: 11977473
i am not worried about screen capture.. let them do that all they want.

How about using pdf's directly? Can i set pdf's to not allow printing, to not allow opening after x amout of time? To only allow to open once.. etc.. etc..

what options are there on pdf security? And can i control all these from php?

Maybe that would work. someone wants to view a document, i make a copy with php, set it to view only and expire after 1 hr.

Can i do that?

Again i'm open to any solution, just need one that works and solves the problem. Lets the views view the document without printint it (ignoring screen caputure since we can't control that ever)

Dan
0
 
LVL 25

Accepted Solution

by:
Squinky earned 500 total points
ID: 11977820
Yes you can do that with regular PDF security. The main things it allows you to lock out are opening, printing and cut/paste. But all of this relies on you using a real PDF, not something similar.
0
 
LVL 1

Author Comment

by:micamedia
ID: 11978638
i can use real pdfs. The source files will all be pdf.

but what if someone loads up the pdf in something other then the acrobat? Say in photoshop, or pagemaker... will it by pass the security?

Now how does it go about locking out opening? with a password? Can you let the user open it for only a certain amout of time?

I'd like to see a pdf that you can open and view (and not print) only for 1 hr, then after that it's useless to you.

Dan
0
 
LVL 25

Expert Comment

by:Squinky
ID: 11979688
All PDF viewers I've encountered honour the security settings, and that includes things like Illustrator (which is probably the most powerful tool for dismantling PDFs otherwise). They have to honour main password settings as the document is encrypted and can't be opened without it.

Any PDF creator/editor (such as Acrobat pro) will allow you to set security settings. It's quite straightforward. It's also pretty easy to add security measures to existing PDFs using tools like PDFPLOP from within PHP. See here:

http://www.pdflib.com/products/plop/index.html

As far as I'm aware, there isn't any means of imposing a time constraint on security settings, though you can probably achieve it by using Javascript within PDFs (PDF has a full javascript environment), though that may not be practical to automate for many documents (PDFLib may have something to say on that subject).

There's lots of other PDF info here:

http://www.pdfzone.com/
0
 
LVL 1

Author Comment

by:micamedia
ID: 11980545
I still dont know what solution is the best. But i have gotten it down to a few options:

1. Use php to extract images of each page from the pdf. Has the problem of letting users easily print the image, unless there is some way I can prevent that? (java image viewer?)

2. Java PDF viewer. Hard to find a simple java pdf viewer. Everything I am finding is an SDK with all sorts of features that i just don't need, and it will probably be very expensive. Why isn't there a simple viewer only? Has the problem of making sure the user has java installed. What if they don't.. then i am requiring them to download that. What are the odds that they will have java installed?

3. Flash PDF viewer. Found flashpaper, which look excellent, but i would have to find a way to covert all the pdf uploads to flash paper, which i don't even know if there is a way. I can mostly assume people have flash installed, and if not it's a pretty automatic process. Is there a flash app that views pdfs out there?

4. Active X viewer? Are there any out there. I haven't seen them. These would work in the microsoft enviroment only right? No mac or anything else, which seems to elimate this solution.

5. Use acrobat reader. Requires the user to download and installed it (any way i can automate this process for them). Let the user download pdf files that have set security on them that do not allow printing. Problems: users have the full pdf file and if they figure out the master password they can do with it what they want. There are programs out there for hacking the master password.

I still feel like ii'm in the woods with this problem. Nothing seems like a perfect answer. The best answer would be a simple java or flash pdf viewer that would allow me to turn off printing. but i have yet to find anything like that.

Dan
0
 
LVL 25

Expert Comment

by:Squinky
ID: 11981284
The Acrobat reader plugin IS an activeX component for Windows. It can be downloaded and installed dynamically when a user hits a page. The Schubert IT plugin for OS X is way better than the Adobe one.

Acrobat passwords are only insecure if you use a crap password. The crackers are all brute-force ones, so will be defeated by a decent passphrase.

Neither a Flash nor a Java solution would solve your problem as they would still have to download the PDF.
0
 
LVL 25

Expert Comment

by:Squinky
ID: 11981341
You've also not ruled out the use of a sample chapter. I don't quite see the requirement of having a PDF viewer as being a problem, as what you're selling access to will require it anyway. It seems completely pointless to make the entire document available as a preview - if it's all there, there's nothing left to buy!

Overall I think you should go with a PDF to image conversion of a small section of each document, and use a DHTML widget to present it (can easily do pan & zoom on an image without Flash or Java). Keep the resolution low, and it will not make much sense to print it. You could also use print-media CSS to make it moderately unprintable. The advantage of this approach is that it can be automated, and has low installation requirements.
0
 
LVL 1

Author Comment

by:micamedia
ID: 11982802
could i also apply a watermark to these image via php couldn't I?

I find myself seeing the using acrobat and password protecting the documents or converting to low res image via php as the primary options. I actually I don't even see using a JAVA or FLASH viewer as a possiblity as I cannot find any of either one.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now