Convert a web page into PDF format, download and save into folder as below.
Include dompdf_config.inc.php file from the library.
Create a folder for saving the PDF file which is generated from the webpage.
<?php <br ?--> require_once "dompdf_config.inc.php"; if(isset($_POST['download'])) { $dompdf = new DOMPDF(); $dompdf->load_html(file_get_contents("yourpagetoconvert")); $dompdf->render(); $dompdf->stream("invoice.pdf", array("Attachment" => false)); $output = $dompdf->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'); readfile($file_to_save); } ?>
HTML code to convert on submit:
Download dompdf library from the github which is free. Click here to download.