Solved

How to display a pdf file when page loads

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Best way to find duplicate message in database 7 32
wordpress limitations 4 116
Create associate webpages / websites 3 81
Cordova Camera plugin fails 2 120
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

832 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