Php 如何在codeigniter中包含pdf下载
我想保留一个按钮来下载pdf文件。但是库文件会显示在视图中。有人请帮帮我。提前谢谢。 控制器代码:Php 如何在codeigniter中包含pdf下载,php,codeigniter,Php,Codeigniter,我想保留一个按钮来下载pdf文件。但是库文件会显示在视图中。有人请帮帮我。提前谢谢。 控制器代码: public function pdf() { //load library $this->load->library('pdf'); $pdf = $this->pdf->load(); // retrieve data from model $data['DocFile'] = $this->Docauth->get_i
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>
查看文件
函数输出中的I
选项将文件内联发送到浏览器。您需要使用D
选项:
$pdf->Output("$output", 'D');
更多信息请点击此处:
@param string:dest
发送文档的目的地。它可能需要一个
以下数值:
I:将文件内联发送到浏览器(默认)。使用插件
如果有的话。当用户选择
生成PDF的链接上的“另存为”选项
D:发送到浏览器并强制下载具有给定名称的文件
名字
F:使用名称指定的名称保存到本地服务器文件
S:以字符串形式返回文档。名称被忽略
FI:相当于F+I期权
FD:相当于F+D选项
您是否尝试过在输出前发送标题信息(内容类型、内容处置)?更重要的是,您尝试过谷歌搜索“pdf下载codeigniter”
。它确实产生了大约1000000件东西,让你看看有多少可能的复制品