【发布时间】:2019-07-05 22:24:09
【问题描述】:
控制器:函数income_reports()
public function income_reports(){
if(isset($_POST["search"])) {
$from=$this->input->post('from_date');
$to=$this->input->post('to_date');
$this->load->model("Home_model");
$data['view_report']=$this->Home_model->income_report($from,$to);
$data['cat_result']=$this->Home_model->add_cat();
$pdfFilePath = "output_pdf_name.pdf";
$this->load->library('m_pdf');
$html = $this->load->view('income_reports',$data,true);
$this->m_pdf->pdf->WriteHTML($html);
$this->m_pdf->pdf->Output($pdfFilePath, "D");
}
}
查看:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title> Income |Report</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
</head>
<div class="wrapper" >
<!-- Main content -->
<section class="invoice">
<!-- Table row -->
<div class="row">
<div class="col-xs-12 table-responsive">
<table class="table-border" cellspacing="50">
<thead>
<tr>
<th>#</th>
<th>Date</th>
<th>Category</th>
<th>Description</th>
<th>Income Amount</th>
</tr>
</thead>
<tbody>
<?php
$total_sum=0;
if($view_report->num_rows() > 0)
{
$i=1;
foreach($view_report->result() as $row)
{
?>
<tr>
<td><?php echo $i++;?></td>
<td><?php echo $row->date;?></td>
<td><?php echo $row->cat_name;?></td>
<td><?php echo $row->description;?></td>
<td><?php echo $row->inc_amount;?></td>
</tr>
<?php
$total_sum+=$row->inc_amount;
}
}
else
{
?>
<tr><td>Not Found</td></tr>
<?php
}
?>
</tbody>
</table>
<div>
<h4 style="color: green; padding-left: 500px;">Total : ₹<?php echo $total_sum ?> !</h4>
</div>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<!-- ./wrapper -->
</body>
</html>
在这段代码中,我创建了一个名为 income_reports.php 的视图文件,现在我想将这些问题导出为 pdf 格式,我正在使用 mpdf CodeIgniter 在其中加载 M_pdf.php 库和 pdf第三方,但它不工作,它向我显示一个错误。
那么,我该如何解决这个问题?请帮帮我。
错误:1)
遇到 PHP 错误 严重性:通知 消息:未定义的属性:m_pdf::$pdf 文件名:控制器/Home.php 行号:156
2)
遇到未捕获的异常 类型:错误 消息:在 null 上调用成员函数 WriteHTML() 文件名:C:\xampp\htdocs\income_expence_manage\application\controllers\Home.php 行号:156
谢谢
【问题讨论】:
-
请将错误添加到帖子中。
标签: javascript php codeigniter