?
Solved

How to display a pdf file when page loads

Posted on 2004-08-16
3
Medium Priority
?
344 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

765 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