convert html to pdf convert html web page to pdf and download conver html to webpage using dompdf convert html webpage to pdf convert url to pdf Convert WebPage to PDF

How to Convert HTML WebPage to PDF Using PHP

Convert a web page into PDF format, download and save into folder as below.

Include file from the library.

Create a folder for saving the PDF file which is generated from the webpage.

<?php &lt;br ?-->  require_once ""; 
   $dompdf = new DOMPDF();
   $dompdf-&gt;stream("invoice.pdf", array("Attachment" =&gt; false));
   $output = $dompdf-&gt;output();
   $file_to_save = 'uploads/filename.pdf';
   file_put_contents($file_to_save, $output);

   //print the pdf file to the screen for saving
   header('Content-type: application/pdf');
   header('Content-Disposition: inline; filename="filename.pdf"');
   header('Content-Transfer-Encoding: binary');
   header('Content-Length: ' . filesize($file_to_save));
   header('Accept-Ranges: bytes');

HTML code to convert on submit:

Download dompdf library from the github which is free. Click here to download.