Web Page To PDF is a simple feature, You can download any web page as PDF format and save to your local drive using Web Page To PDF Converter. This is an important tool for a website to increase impression and user experience. Today I am going to discuss convert web page to pdf using PHP. It's a good service so that webmasters eager to convert web page to pdf using php and randomly searching for web page to pdf php script. It's pretty easy to Creating PDF in PHP. We use mpdf library to make this. Follow the step by step instruction to install this.
Download mPDF Library
At first, download the mPDF library and extract it. Then create a file to execute PDF. I am going to create an index.php file to make an example. Create this file and write down this code.
The Web To PDF maker is ready. If you execute this script this script will create a PDF of example.com and download it. If you want only show PDF in browser than leave $mpdf->Output(); value empty.
$site = 'http://example.com';
$title = 'myPDF'; // Your own title
include("mpdf.php"); //include mpdf.php file from mPDF library
$mpdf=new mPDF('win-1252','A4','','',15,10,16,10,10,10);//A4 page in portrait for landscape add -L.
$mpdf->useOnlyCoreFonts = true;
$file = file_get_contents($site);
echo $file; //this is webpage content
$html = ob_get_contents();
//$mpdf->SetProtection(array(), 'user', 'password'); uncomment to protect your pdf page with password. // If you want to use password.
I hope you understand how to convert a web page to PDF in PHP. If you have any question or comment about this Web Page To PDF Converter in PHP article please don't hesitate to do that, please comment your question in comment section.