DISPLAY THE PDF FILE USING PHP

1
This tutorial is shows how to display the pdf file using php, In below coding store the pdf url  in file variable and then you should mention the pdf file name in filename variable,  @readfile($file); is used display the pdf file in php.

This concept is very helpful for the php developers who want to display the pdf file in our websites.

display pdf file

Display the PDF file using PHP:

<!doctype html>
<html>
<head>
<meta charset=”utf-8″>
<title>Display the pdf file using php</title>
</head>
<body>
<?php
$file = ‘./pdf/seo.pdf’;
$filename = ‘seo.pdf’;
header(‘Content-type: application/pdf’);
header(‘Content-Disposition: inline; filename=”‘ . $filename . ‘”‘);
header(‘Content-Transfer-Encoding: binary’);
header(‘Content-Length: ‘ . filesize($file));
header(‘Accept-Ranges: bytes’);
@readfile($file);
?>
<a href=”http://www.sanwebtutorials.blogspot.in/”>San web corner</a>
</body>
</html>

Download Code

Leave a Reply

Your email address will not be published. Required fields are marked *

Close
Your custom text © Copyright 2026. All rights reserved.
Close