SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru ripcurlksm's Avatar
    Join Date
    Aug 2004
    Location
    San Clemente, CA
    Posts
    857
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why wont this PDF header() work?

    Why wont the header() parse the pdf? It shows up as encripted with weird characters. If $type = 1, it is a pdf and i have to parse it with a PDF header, else if it is $type = 2 do something else.

    My issue is with this header, does it have to appear on the first line on the page? how can i have a script switch out header() types for different types of content?

    Code PHP:
    <html>
    <head>
    </head>
    <body>
    <?php 
    $type = $_GET['type']; 
     
    if ( $_SESSION['valid_user'] ) 	{ 
     
    	if ($type == "1"){
     
    	$fileName = "pdf/filename.pdf";	
     
    	header("Content-type: application/pdf");  
    	readfile($fileName);
     
     
    	} else if ($type == "2"){
    	// DO THIS
     
     
    } else { 
    echo "You do not have permision to view this page";
    }
    ?>
    </body>
    </html>

  2. #2
    SitePoint Guru Ruben K.'s Avatar
    Join Date
    Jun 2005
    Location
    Alkmaar, The Netherlands
    Posts
    693
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You have HTML before your header() call, if you were to turn this into application/pdf it wouldn't work

  3. #3
    SitePoint Wizard Hammer65's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln Nebraska
    Posts
    1,161
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Get rid of the HTML, because right now your document is having an identity crisis. After you do that, read the section in the manual on header, including the attached comments. Also take a look at the FAQ at fpdf.org and the fpdf source for information about difficulties with PDF and IE. Suffice it to say, that you will need far more than just a content-type header to make it work cross browser.
    Visit my blog
    PHP && Life
    for technology articles and musings.

  4. #4
    SitePoint Guru ripcurlksm's Avatar
    Join Date
    Aug 2004
    Location
    San Clemente, CA
    Posts
    857
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats it, thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •