DISPLAY THE PDF FILE USING PHP

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

Post a Comment

0 Comments