Show PDF file in PHP

If you want to show your PDF file in PHP, you can put the code as follow :



header(‘Content-type: application/pdf’);

header(‘Content-Disposition: attachment; filename=”‘.pdf.'”‘);



Note : The above code will open/ save PDF file as attachment. If you want to show the PDF file directly into same window, you can change the Content-disposition type into inline. So, the line

header(‘Content-Disposition: attachment; filename=”‘.pdf.'”‘);” should be change into :

header(‘Content-Disposition: inline; filename=”‘.pdf.'”‘);


There is many option can be used for header field in PHP. For complete reference, you can follow this link :

Hope this article can be useful.