I have a problem reading a pdf file in Chrome using PHP.
The following code is how I do in PHP
$path = "actually file path"; header("Pragma: public"); header("Expires: 0"); header("Content-type: $content_type"); header('Cache-Control: private', FALSE); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header("Content-Disposition: inline; filename=\"$filename\""); header('Content-Transfer-Encoding: binary'); header('Content-Length' . filesize($path)); ob_clean(); flush(); readfile($path);
Here I set the Content-Disposition to a string. Because I want to display a pdf file if the plugin for viewing PDF files is built in the user's browser. As you know, Chrome has a built-in pdf viewer.
The problem is that I have a bunch of pdf files on the server. Chrome can only view some of them. I cannot understand why others cannot work the same way. I checked the resolution of each file. This does not seem to be a resolution problem.
Does anyone know what the problem is? Thanks.
source share