【发布时间】:2017-07-21 08:24:52
【问题描述】:
我想保留一个按钮来下载 pdf 文件。但是库文件会显示在视图中。有人请帮助我。在此先感谢。 控制器代码:
public function pdf()
{
//load library
$this->load->library('pdf');
$pdf = $this->pdf->load();
// retrieve data from model
$data['DocFile'] = $this->Docauth->get_items();
$data['DocFileName'] = "items";
ini_set('memory_limit', '256M');
// boost the memory limit if it's low ;)
$html = $this->load->view('Docauth_v', $data, true);
// render the view into HTML
$pdf->WriteHTML($html); // write the HTML into the PDF
$output = 'Docauth' . date('Y_m_d_H_i_s') . '_.pdf';
$pdf->Output("$output", 'I'); // save to file because we can
exit();
查看文件
<div class="form-group">
<label class="control-label col-md-3">View File</label>
<div class="col-md-5">
<input name="DocFile" id="DocFile" class="form-control"` type="text" >
</div>
<a href="Docauth/pdf"><span class="glyphicon glyphicon-plus"></span></a>
</div>
【问题讨论】:
-
您是否尝试过在输出前发送标头信息(内容类型、内容处置)?
-
更重要的是您是否尝试过谷歌搜索
"pdf download codeigniter"。它确实会生成大约 1,000,000 件东西供您查看
标签: php codeigniter