Convert HTML To PDF In PHP With Dompdf Example
Hi guys,
Today i will explained how to convert html to pdf in php with using dompdf. This example is so easy to use in php. This example to i am use to dompdf and create html file to pdf view and dowload pdf file using php.
So First dowload to the dompdf generater in your folder.So let's start to the example.
index.php
<?php
require_once 'dompdf/autoload.inc.php';
use Dompdf\Dompdf;
$dompdf = new Dompdf();
// Load HTML content
// $dompdf->loadHtml('<h1>Welcome to niceshipest.com</h1>');
// Load html file
$html = file_get_contents("index_pdf.html");
$dompdf->loadHtml($html);
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream("niceshipest", array("Attachment" => 0));
?>
Pdf View
Index_pdf.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Convert HTML To PDF In PHP With Dompdf</title>
</head>
<body>
<h1>
Pdf File Generate To Niceshipest.com
</h1>
</body>
</html>
Now you can check your own.
Output :
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example