0
votes

want to display pdf in php so i created following code

$file = '../public/'.$ref;
header('Content-Type: application/pdf');
header('Content-Disposition: inline; filename="' . $filename . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');  

@readfile($file);

but browser showing weird contents , like below image enter image description here

i changed Content-Disposition in to attachment, its working fine but no luck in inline what i can do to fix this issue thanks in advance

1
What do you want exactly ? for example show the content into a div ?may saghira
There are couple things you can do. 1) Remove these two lines: header('Content-Transfer-Encoding: binary'); header('Accept-Ranges: bytes'); 2)Try different browser. Are you sure that your browser can load PDF inline? Does it do for other sites? Ideally, Content-Disposition: attachment; is more common, unless you have specific requirement.Kamal Soni
thank you for your reply , i tried what you said , also tried different browser but no luckRathilesh C

1 Answers

0
votes

finally code is working , i comment following lines in bootstrap.php file

 public static function sendResponse(Zend_Controller_Response_Http $response)
{
   //$response->setHeader('Content-Type', 'text/html; charset=iso-8859-1', true);
   $response->sendResponse();
}

but i need this charset in my response header , there is any other method?