How to open pdf file on button click in php

View Discussion

Improve Article

Save Article

  • Read
  • Discuss
  • View Discussion

    Improve Article

    Save Article

    PHP uses a standard code to display the pdf file in web browser. The process of displaying pdf involves location of the PDF file on the server and it uses various types of headers to define content composition in form of type, Disposition, Transfer-Encoding etc. PHP passes the PDF files to read it on the browser. Browser either shows it or download it from localhost server then display pdf.

    Note: PHP is not actually reading the PDF file. It does not recognize File as pdf. It only passes the PDF file to the browser to be read there. If copy the pdf file inside htdocs folder of XAMPP then it does not need to specify the file path.

    Example 1: This example display the pdf file on the browser.

    Chủ Đề