Ver Mensaje Individual
  #2 (permalink)  
Antiguo 09/07/2013, 12:23
Avatar de destor77
destor77
 
Fecha de Ingreso: noviembre-2004
Ubicación: Gálvez, Santa Fe, Argentina
Mensajes: 2.654
Antigüedad: 19 años, 5 meses
Puntos: 43
Respuesta: Integrar HTMLPDF en Codeigniter

yo no lo uso como una libreria integrada de CI, lo que hago es incluirlo y listo con ese alcanza y sobra te dejo mi ejemplo que uso para crear un adjunto en pdf o imprimirlo desde la pagina web.
Código PHP:
Ver original
  1. require_once(APPPATH.'libraries/html2pdf/html2pdf.class.php');
  2.         $html2pdf = new HTML2PDF('P', 'A4', 'es');
  3.         //$html = $this->load->view('presupuestos/imprimir',true);
  4.         //$this->firephp->info($html2pdf->getHtmlFromPage($html));
  5.  
  6.         $html = '<!DOCTYPE html>';
  7.         $html .= '<head>
  8.        <link href="'.base_url('assets/css/bootstrap.css').'" rel="stylesheet" type="text/css" />
  9. <link href="'.base_url('assets/css/styling.css').'" rel="stylesheet" type="text/css" />
  10. <link href="'.base_url('assets/css/stylesheet.css').'" rel="stylesheet" type="text/css" />
  11. <link href="'.base_url('assets/css/mystyles.css').'" rel="stylesheet" type="text/css" />';
  12.         $html .= '</head>
  13. <html lang="en">
  14.    <body class="smw">
  15.    <div class="content">
  16.    <div class="invoice">
  17.        <table style="border:none">
  18.    <tr>
  19.        <td colspan="3" style="border:none">
  20.            <h1 style="color: #42536D;font-size: 30px;line-height: 34px;margin: 0;">Presupuesto #'.$nro.'</h1>
  21.            <span style="color: #333333;display: block;font-size: 12px;font-weight: bold;line-height: 16px;margin-bottom: 50px;">Fecha: '.$this->input->post('fecha').'</span>
  22.        </td>
  23.    </tr>
  24.    <tr>
  25.        <td style="border:none">
  26.            <div class="span3">
  27.                <h4 style="border-bottom: 1px solid #DDDDDD;color: #42536D;font-size: 20px;line-height: 34px;">Domicilio Entrega</h4>
  28.                <address>
  29.                    <strong>'.$cliente['nombre'].'</strong><br>
  30.                    '.$entrega['direccion'].'<br>
  31.                    '.$entrega['ciudad'].', '.$entrega['provincia'].' '.$entrega['cp'].' '.$pais_e['nombre'].'<br>
  32.                    <span title="Phone">P:</span> '.$cliente['telefono'].'
  33.                </address>
  34.            </div>
  35.        </td>
  36.        <td style="border:none">
  37.            <div class="span3">
  38.                <h4 style="border-bottom: 1px solid #DDDDDD;color: #42536D;font-size: 20px;line-height: 34px;">Domicilio Facturaci&oacute;n</h4>
  39.                <address>
  40.                    <strong>'.$cliente['nombre'].'</strong><br>
  41.                    '.$facturacion['direccion'].'<br>
  42.                    '.$facturacion['ciudad'].', '.$facturacion['provincia'].' '.$facturacion['cp'].' '.$pais_f['nombre'].'<br>
  43.                    <span title="Phone">P:</span> '.$cliente['telefono'].'
  44.                </address>
  45.            </div>
  46.        </td>
  47.        <td style="border:none">
  48.            <div class="span3">
  49.                <h4 style="border-bottom: 1px solid #DDDDDD;color: #42536D;font-size: 20px;line-height: 34px;">Empresa</h4>
  50.                <address>
  51.                    <strong>'.$empresa[0]['nombre'].'</strong><br>
  52.                    '.$empresa[0]['direccion'].'<br>
  53.                    '.$empresa[0]['ciudad'].', '.$empresa[0]['provincia'].' ('.$empresa[0]['cp'].') '.$empresa[0]['pais'].'<br>
  54.                    <span>Tel:</span> '.$empresa[0]['telefono'].'<br/>
  55.                    Presupuest&oacute;: <strong>'.$this->session->userdata('ba_fullname').'</strong>
  56.                </address>
  57.            </div>
  58.        </td>
  59.    </tr>
  60.    <tr>
  61.        <td colspan="3" style="border:none"><h3 style="border-bottom: 1px solid #DDDDDD;color: #42536D;font-size: 20px;line-height: 34px;">Detalle</h3></td>
  62.    </tr>
  63.    <tr style="width:600px">
  64.        <td style="width:600px" colspan="3" style="border:none;width:600px;" >
  65.            <table style="width:600px" cellspacing="0" cellpadding="0">
  66.                <thead>
  67.                    <tr>
  68.                        <th width="20%">Familia</th>
  69.                        <th width="55%"></th>
  70.                        <th width="5%">Cantidad</th>
  71.                        <th width="10%">Descuento (%)</th>
  72.                        <th width="10%">Importe</th>
  73.                    </tr>
  74.                </thead>
  75.                <tbody>';
  76.         $total_item = count($items['item_id']);
  77.         for($i = 0; $i < $total_item; $i++){
  78.             $html .= '<tr>
  79.                            <td>'.$items['nombre'][$i].'</td>
  80.                            <td>'.$items['descripcion'][$i].'</td>
  81.                            <td>'.$items['cantidad'][$i].'</td>
  82.                            <td style"text-align:right">'.$items['descuento'][$i].'</td>
  83.                            <td style"text-align:right">'.number_format($items['precio'][$i],2,',','.').'</td>
  84.                        </tr>';
  85.         }
  86.         $html .= '
  87.                    <tr>
  88.                        <td colspan="3" style="border:none"></td>
  89.                        <td colspan="2" style="border:none">
  90.                            <p><strong><span>Subtotal:</span> <span>'.number_format($subtotal,2,',','.').'</span> &euro; </strong></p>
  91.                            <p><strong><span>Descuento Gral (%): '.$desc_gral.' %</span></strong></p>
  92.                            <p><strong><span>Total:</span> <span>'.number_format($total,2,',','.').'</span> &euro; </strong></p>
  93.                        </td>
  94.                    </tr>
  95.                </tbody>
  96.            </table>
  97.        </td>
  98.    </tr>
  99. </table>
  100. </div>
  101. </div>
  102.    </body>
  103. </html>';
  104.         if($email){
  105.             try
  106.             {
  107.                 $this->load->helper('date');
  108.                 $html2pdf->writeHTML($html);
  109.                 /*$content_PDF = $html2pdf->Output('', true);
  110.                 return $content_PDF;*/
  111.                 $nombre = APPPATH.'third_party/presupuesto_'.$this->session->userdata('ba_id_empresa').'_'.$cliente['clientes_id'].'_'.now();
  112.                 $html2pdf->Output($nombre.'.pdf', 'F');
  113.                 return $nombre;
  114.             }
  115.             catch(HTML2PDF_exception $e) {
  116.                 echo $e;
  117.                 exit;
  118.             }
  119.         }
  120.         else{
  121.             try
  122.             {
  123.                 $html2pdf->writeHTML($html);
  124.                 $html2pdf->Output('my_doc.pdf');
  125.             }
  126.             catch(HTML2PDF_exception $e) {
  127.                 echo $e;
  128.                 exit;
  129.             }
  130.         }
  131.  
  132.     }

salu2