title: how to view table data in tcpdf
body: <p>i'm a new one for codeigniter and tcpdf. now i want to show my database table row in pdf. i don`t know how to do that. any one can help me please where i should insert the code and how to write the code.</p>
  
  <p>this is the code for pdf generator</p>
  
  <pre><code>    &lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  class Createpdf extends CI_Controller {
  
      function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;library("Pdf");
      }
  
      public function create_pdf() {
  
      // create new PDF document
      $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);    
  
      // set document information
      $pdf-&gt;SetCreator(PDF_CREATOR);
      $pdf-&gt;SetAuthor('lakmini');
      $pdf-&gt;SetTitle('RCJ CONSTRUCTIONS');
      $pdf-&gt;SetSubject('TCPDF Tutorial');
      $pdf-&gt;SetKeywords('TCPDF, PDF, example, test, guide');   
  
      // set default header data
      $pdf-&gt;SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH, PDF_HEADER_TITLE.' 001', PDF_HEADER_STRING, array(0,64,255), array(0,64,128));
      $pdf-&gt;setFooterData(array(0,64,0), array(0,64,128)); 
  
      // set header and footer fonts
      $pdf-&gt;setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
      $pdf-&gt;setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));  
  
      // set default monospaced font
      $pdf-&gt;SetDefaultMonospacedFont(PDF_FONT_MONOSPACED); 
  
      // set margins
      $pdf-&gt;SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
      $pdf-&gt;SetHeaderMargin(PDF_MARGIN_HEADER);
      $pdf-&gt;SetFooterMargin(PDF_MARGIN_FOOTER);    
  
      // set auto page breaks
      $pdf-&gt;SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM); 
  
      // set image scale factor
      $pdf-&gt;setImageScale(PDF_IMAGE_SCALE_RATIO);  
  
      // set some language-dependent strings (optional)
      if (@file_exists(dirname(__FILE__).'/lang/eng.php')) {
          require_once(dirname(__FILE__).'/lang/eng.php');
          $pdf-&gt;setLanguageArray($l);
      }   
  
      // ---------------------------------------------------------    
  
      // set default font subsetting mode
      $pdf-&gt;setFontSubsetting(true);   
  
      // Set font
      // dejavusans is a UTF-8 Unicode font, if you only need to
      // print standard ASCII chars, you can use core fonts like
      // helvetica or times to reduce file size.
      $pdf-&gt;SetFont('dejavusans', '', 14, '', true);   
  
      // Add a page
      // This method has several options, check the source code documentation for more information.
      $pdf-&gt;AddPage(); 
  
      // set text shadow effect
      $pdf-&gt;setTextShadow(array('enabled'=&gt;true, 'depth_w'=&gt;0.2, 'depth_h'=&gt;0.2, 'color'=&gt;array(196,196,196), 'opacity'=&gt;1, 'blend_mode'=&gt;'Normal'));    
  
      // Set some content to print
      $html = &lt;&lt;&lt;EOD
      &lt;h1&gt; this is my first pdf &lt;/h1&gt;
  EOD;
    // Print text using writeHTMLCell()
      $pdf-&gt;writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);   
  
      // ---------------------------------------------------------    
  
      // Close and output PDF document
      // This method has several options, check the source code documentation for more information.
      $pdf-&gt;Output('example_001.pdf', 'I');    
  
      //============================================================+
      // END OF FILE
      //============================================================+
      }
  }
  </code></pre>
  
  <p>this is my db table</p>
  
  <pre><code> CREATE TABLE IF NOT EXISTS `staff` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `designation_id` int(11) NOT NULL,
    `first_name` varchar(50) NOT NULL,
    `last_name` varchar(50) NOT NULL,
    `email` varchar(50) NOT NULL,
    `address` varchar(50) NOT NULL,
    `password` varchar(50) NOT NULL,
    `contact_no` int(11) NOT NULL,
    `work_experience` varchar(250) NOT NULL,
    `qualifications` varchar(250) NOT NULL,
    `nic` varchar(10) NOT NULL,
    `gender` varchar(10) NOT NULL,
    `created` date NOT NULL,
    `firstname` varchar(50) NOT NULL,
    `lastname` varchar(50) NOT NULL,
    PRIMARY KEY (`id`),
    KEY `designation_id` (`designation_id`)
  ) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=22 ;
  </code></pre>