This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Showing posts with label pdf. Show all posts
Showing posts with label pdf. Show all posts

Friday, January 28, 2011

Exsport to PDF with dompdf in Code Igniter

  1. cDownload dompf from here and exstract the file.
  2. Then put to the directory ./system/application/plugins/.
  3. After that then create new file on ./system/application/plugins/dompdf_pi.php like this
  4. <?php
    
    if (!defined('BASEPATH'))
        exit('No direct script access allowed');
    
    /**
     * Try increasing memory available, mostly for PDF generation
     */
    ini_set("memory_limit", "32M");
    
    function pdf_create($html, $filename, $stream=TRUE, $orientation="portrait") {
        require_once(BASEPATH . "application/plugins/dompdf/dompdf_config.inc.php");
    
        $dompdf = new DOMPDF();
        $dompdf->set_paper("a4", $orientation);
        $dompdf->load_html($html);
        $dompdf->render();
        if ($stream) { //open only
            $dompdf->stream($filename . ".pdf");
        } else { // save to file only, your going to load the file helper for this one
            write_file("pdf/$filename.pdf", $dompdf->output());
        }
    }
    
    ?>
  5. Create controler mypdf.php
  6. <?php
    
    /**
     * @property CI_DB_active_record $db
     */
    class mypdf extends MY_Controller {
    
        function mypdf() {
            parent::MY_Controller();
      $this->load->plugins('dompdf_pi');
        }
    
        function index() {
         $html="Hello Word";
      $filename="Mypdf";
            pdf_create($html, $filename, $stream=TRUE, $orientation='portrait');
        }
    
     }
    ?>