Solved

How to display a pdf file when page loads

Posted on 2004-08-16
3
283 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to dynamically set the form action using jQuery.

758 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

17 Experts available now in Live!

Get 1:1 Help Now