Read a PDF File using php

From: Date: Wed, 01 Oct 2003 19:27:18 +0000
Subject: Read a PDF File using php
Groups: php.general 
Request: Send a blank email to php-general+get-164603@lists.php.net to get a copy of this message
Hello All I need to allow a user to access a PDF file, only if he/she is logged in as a registered user. So here is the code that I am trying to use. I have been able to make this work in the past, when I had to read .html file, now since the file in question is a .pdf file, I am having trouble. The browser shows a long list of weird characters instead of the pdf file if(session_is_registered("user_valid")){ $filepath ="docs/any_file.pdf"; $h1 = @fopen($filepath,"r"); while (!feof($h1)) {
    $a = fread($h1,4096);
echo "$a";
    }
} Any ideas / suggestions would be welcome. Thanks in advance Pushpinder

« previous php.general (#164603) next »