Get complete CodeIgniter blog project for free!

Downloaded more than 161 times, this is full project must-study for serious developers!

By submitting this form, you agree to our Terms of Service and Privacy Policy.

Web Page To PDF Converter in PHP

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.

$site = '';
$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.
The Web To PDF maker is ready. If you execute this script this script will create a PDF of and download it. If you want only show PDF in browser than leave $mpdf->Output(); value empty.

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.

Search on PHPAns
Subscribe to PHPAns
Join with our 32000+ subscribers and get our latest articles in your email inbox for free.
Delivered by FeedBurner
We always respect your privacy and take protecting it seriously.
Connect Social With PHPAns