Page 1 of 1

Displaying pdf file on a browser

Posted: Mon Oct 28, 2013 6:36 am
by HUNDU2
Please i'm working on how display pdf file on a browser but each time i try i get this error.
This file can not be display correctly.
Please i your help.
Thanks in advanced


***** Please use PHP Code syntax tag *****

Code: Select all

<?php
mysql_connect("localhost", "root", "") or die ("Could not save image name Error: " . mysql_error());
mysql_select_db("pdf") or die("Could not select database");
$data = mysql_query("SELECT * FROM pdf2 where id='2'") or
die(mysql_error());
while($row = mysql_fetch_assoc( $data ))
{
$src=$row['path'];
$file ='http://localhost/pdf/images/';;
$filename =$src; 

header('Content-type: application/vnd.abode.xfdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');

@readfile($file);
}
?>

Re: Displaying pdf file on a browser

Posted: Mon Oct 28, 2013 9:35 am
by Christopher
It is "adobe" not "abode". Try 'Content-type: application/vnd.adobe.xfdf'

How to DISPLAY PDF FILE ON A BROWSER

Posted: Mon Oct 28, 2013 11:22 am
by HUNDU2
Please i have been trying to display a pdf file on a browser, but it is not working. This is my code
I will be happy with any assistance.
Thanks in advanced.
this is my error message.
Adobe Reader could not open this file because it is either not a supported type or the file is damaged

<?php
mysql_connect("localhost", "root", "") or die ("Could not save image name Error: " . mysql_error());
mysql_select_db("pdf") or die("Could not select database");
$data = mysql_query("SELECT * FROM pdf2 where id='2'") or
die(mysql_error());
while($row = mysql_fetch_assoc( $data ))
{//Outputs the image and other data
$src=$row['path'];
$file ='http://localhost/pdf/images/';
$filename =$src; /* Note: Always use .pdf at the end. */

header('Content-type: application/vnd.adobe.xfdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Content-Length: ' . filesize($file));
header('Accept-Ranges: bytes');

@readfile($file);
}
?>

Re: How to DISPLAY PDF FILE ON A BROWSER

Posted: Mon Oct 28, 2013 2:57 pm
by Christopher
Try MIME type 'application/pdf'.