Solved

How to display a pdf file when page loads

Posted on 2004-08-16
3
325 Views
Last Modified: 2010-04-06
Hi All
probably a simple one but here goes anyway.

How do I get a webpage to display a pdf file (open up acrobat reader etc) everytime it is loaded. It must be done in PHP (I want to password protect it and have the code in place for it).

Many thanks in advance

Michael

0
Comment
Question by:daleoran
  • 2
3 Comments
 
LVL 3

Expert Comment

by:thecode101
ID: 11811932
insert this line to the top of the page:
<?php
header ("Location: path/to/thepdffile.pdf");
exit;
?>

That will redirect the page to the pdf file.
0
 
LVL 10

Author Comment

by:daleoran
ID: 11811977
Many thanks for the reply.
adding that code causes the coding of the pdf file to be displayed e.g

%PDF-1.3 %Ç쏢 5 0 obj <> stream xœì½Ý¯n¹qÞ [¶lþ”%;vœÇ“8Éôñâç"oƒ æÆsã»Î$Žáã3€ƒùï‡Ïï)®½·Þwwï–ÚR·óJÐÖsÈwñ£ªH‹Åâß?S~:ôß >ÿôáï?üù_Χÿúÿ~øû§”BòYÛSšµ?µvýèÏÿ2OÿÛÿóá/Ö¯ÆÇ¢ÿð×øóOOÿáGúeyJécO?ú/ŽsŽc4~žÊy~ã©÷ù±ô§}

I need the file to be displayed properly - open acrobat reader and display the formatted document

Again many thanks

Michael

0
 
LVL 3

Accepted Solution

by:
thecode101 earned 500 total points
ID: 11812138
What browser are you using? It worked fine for me in IE 6.0, Firefox, and Netscape 7.1. You could try changing it to (not sure if it will have any affect):

<?php

header("Content-type: application/pdf");
header ("Location: path/to/thepdffile.pdf");
exit;

?>
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

740 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