?
Solved

Display PDF document on PHP page

Posted on 2007-07-25
9
Medium Priority
?
3,973 Views
Last Modified: 2013-12-13
Hi,

I need to write a php script which will output some instructions on top and display the pdf document (not attachment) below the instructions on the same page. It would be best if i cant right click or save the pdf document. How do i go abt it? Need any 3rd party other than Acrobat?

Thanks
0
Comment
Question by:pajiao
  • 6
  • 3
9 Comments
 
LVL 13

Expert Comment

by:MasonWolf
ID: 19571979
A better question is how to embed a pdf in an html page.

This is the answer:

  <OBJECT  WIDTH=555 HEIGHT=450 TYPE="application/pdf">
    <PARAM NAME="SRC" VALUE="file.pdf">
    <EMBED SRC="file.pdf" HEIGHT=450 WIDTH=555> <NOEMBED> Your browser does not support embedded PDF files. </NOEMBED> </EMBED>
  </OBJECT>
0
 

Author Comment

by:pajiao
ID: 19579855
Great thanks Mason, but is there any other way to have a acrobat control with no right clicks and toolbars so that the user is unable to save?
0
 
LVL 13

Expert Comment

by:MasonWolf
ID: 19579880
No problem. Instead of "file.pdf" use "file.pdf#toolbar=false".
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 13

Expert Comment

by:MasonWolf
ID: 19579886
Less sure about disabling right-clicking over the pdf. I'm confident it can be done with javascript, but I'm not sure how. Might want to post the question in that zone.
0
 

Author Comment

by:pajiao
ID: 19579933
Hi Mason, adding $toolbar=false doesnt seems to have any effect at all.
0
 
LVL 13

Expert Comment

by:MasonWolf
ID: 19580013
You're right, my bad. This is why it's always smart to test an answer before I put it up.

It looks like IE recognizes the object type and helpfully brings up the toolbar anyway, even with the modifier. The solution is to take it out of the object tags. A quick test also shows that #toolbar=false works in IE, but not FF. #toolbar=0 works in both.

So, here's the better way:

<EMBED SRC="file.pdf#toolbar=0" HEIGHT=450 WIDTH=555> <NOEMBED> Your browser does not support embedded PDF files. </NOEMBED> </EMBED>

See if that's what you need.
0
 

Author Comment

by:pajiao
ID: 19580160
Hi Mason, the new tags didnt manage to hide out the acrobat toolbars (using arobat 8 reader). The pdf did not even appear in mozilla.
0
 
LVL 13

Accepted Solution

by:
MasonWolf earned 2000 total points
ID: 19581989
I don't know why Mozilla would have a problem with displaying an embedded pdf. Does it normally open a pdf correctly?

Anyway, here is the complete documentation from adobe about what parameters you may specify when opening a pdf by URL:

http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf

The following code worked well for both IE 7 and FF 2 when I tried it:

<EMBED SRC="file.pdf#toolbar=0&statusbar=0&messages=0&navpanes=0" HEIGHT=450 WIDTH=555> <NOEMBED> Your browser does not support embedded PDF files. </NOEMBED> </EMBED>

However, the acrobat plugin on my computer still allowed me to reset the toolbar and I was then able to save my test pdf to my hard drive. Now that you know how to embed a pdf in a webpage, you might want to start a new topic asking how to prevent someone from being able to save that embedded pdf. I don't know whether or not it can be done. But if it can, there's a good chance someone at EE knows how to do it.
0
 
LVL 13

Expert Comment

by:MasonWolf
ID: 19581999
By the way, the object tags are not necessary. I had to remove them in order to display the pdf in FF.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 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