Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to integrate pdf/dompdf Export option with CakePHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 580
    Comment on it

    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.


    App::import('Vendor', 'Fpdf', array('file' => 'fpdf/fpdf.php'));
    App::uses('AppController', 'Controller');
    App::uses('AppController', 'Controller');
    App::import('Vendor', 'PHPExcel');
    App::import('Vendor', 'dompdf',array('file' => 'dompdf/'));
    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>
            $html = '<html>
            <p>Evon Employees List:</p>
            <table border=1>
          $output = $dompdf->output();
          file_put_contents("domfile.pdf", $output);



    <!DOCTYPE html>
    <h2 style="color:green">File successfully save in your webroot folder. Just explore the folder to see it</h2>
    <div class="link-video">                          


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: