Integration of dompdf library is available online,just download it and save this library to vendor folder, this file is able to convert a html document in pdf format, by using this library the content of the page should look more appropriate and attractive and gives new look to the plain html text and css style included text. It contain dom configuration which override the default configuration.
This is simple line of code below that will help user for designing the document in pdf form.
UsersController:
<?php
App::import('Vendor', 'Fpdf', array('file' => 'fpdf/fpdf.php'));
App::uses('controller','controller');
App::uses('AppController', 'Controller');
App::uses('AppController', 'Controller');
App::import('Vendor', 'PHPExcel');
App::import('Vendor', 'dompdf',array('file' => 'dompdf/dompdf_config.inc.php'));
class UsersController extends AppController {
public $components = array('PhpExcel');
public function dompdf()
{
$dompdf = new dompdf();
$result = $this->User->find('all');
$html1= "";
foreach ($result as $value) {
$html1 = $html1."<tr><td>".$value['User']['id']."</td>
<td>".$value['User']['name']."</td>
<td>".$value['User']['number']."</td>
<td>".$value['User']['address']."</td>
<td>".$value['User']['email']."</td></tr>";
}
$html = '<html>
<body>
<p>Evon Employees List:</p>
<table border=1>
<tr>
<th>ID</th>
<th>Name</th>
<th>number</th>
<th>address</th>
<th>email</th>
</tr>'.$html1.'
</table>
</body>
</html>';
$dompdf->load_html($html);
$dompdf->render();
$output = $dompdf->output();
file_put_contents("domfile.pdf", $output);
}
dompdf.ctp
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h2 style="color:green">File successfully save in your webroot folder. Just explore the folder to see it</h2>
<div class="link-video">
</div>
</body>
</html>
0 Comment(s)