使用codeigniter的dompdf库无法使用hmtl和css

时间:2019-01-19 06:07:50

标签: php html5 pdf codeigniter-3 dompdf

我正在使用dompdf库下载pdf格式。首先创建HTML格式的pdf模板,然后创建一个用于调用dompdf库并查看pdf下载功能的函数,但是它不适用于CSS和HTML标签。下面显示了控制器的功能

$this->load->library('Pdf');
    $id=$this->uri->segment(3);
     $data['title']='Invoice';
    $data['invoice_view']= $this->Invoice_Model->get_purchaseorder_by_id($id);
    $this->load->view('components/pdftemplate',$data);
    $html = $this->output->get_output();

     $dompdf=new DOMPDF();
     $dompdf->load_html($html);
     $dompdf->render();
     $dompdf->stream("invoice.pdf");enter code here

然后创建了html模板

<div class="block">
    <div class="row">
        <div class="col-md-6">
            <p>company Logo</p>
        </div>
        <div class="col-md-6"  style="float:left;color:red;">
            <p>Purchase Order</p>
        </div>
    </div>
    <div class="app-heading app-heading-small">                                
        <div class="title">
            <h5><?= $title;?></h5>
        </div>
    </div>
    <?php foreach($invoice_view as $inv):?>
     <div class="row">
            <div class="col-md-6">
               <div class="app-widget-informer">
                    <div class="title">To:<?= $inv->client_company_name;?></div>
                    <div class="tinyintval"><?= $inv->address;?></div>    
                    <div class="tinyintval"></div>                                                                             
                    <div class="tinyintval">Phone:<?= $inv->phone;?></div>
                    <div class="tinyintval">Email:<?= $inv->email;?></div>
               </div>
          </div>
            <div class="col-md-6">
                <div class="app-widget-informer">   
                    <div class="tinyintval">Po#:<?= $inv->invoice_id;?></div>                                        
                    <div class="tinyintval">Po Date:<?= $inv->issue_date;?></div>                                         
                </div>
            </div>                                
    </div>
                    <table class="table table-bordered" >
                        <thead>
                            <th>slno </th>
                            <th> Description</th>
                            <th>Unit Price</th>
                            <th>Quantity</th>
                            <th>Cost</th>
                            <th>Tax %</th>
                        </thead>
                       <tbody>
                       <?php foreach($inv->tableinvoice as $tabin):?>
                                <tr >
                                    <td>
                                    <?= $tabin->id; ?>
                                    </td>       
                                    <td>
                                    <?= $tabin->description; ?>
                                     </td>
                                    <td>
                                    <?= $tabin->quantity; ?>
                                    </td>
                                    <td>
                                    <?= $tabin->unitprice; ?>
                                    </td>
                                    <td>
                                    <?= $tabin->cost; ?>
                                    </td>
                                    <td>
                                    <?= $tabin->tax; ?>
                                    </td>
                               </tr>
                               <?php endforeach;?>      
                        </tbody>
                     </table>
                   <?php endforeach;?>
    </div>

但是获取文本格式无法使用CSS和html样式。

0 个答案:

没有答案