Solved

How to display a pdf file when page loads

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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

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

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…
There are two main kinds of selectors in CSS: One is base selector like h1, h2, body, table or any existing HTML tags.  For instance, the following rule sets all paragraphs (<p> elements) to red: (CODE) CSS also allows us to define our own custom …
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

726 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