- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
只是一个简短的问题。任何人都知道是否可以将多个 View 从 codeigniter 加载到 mpdf Controller 并将其转换为 pdf?我的 Controller :`
<?php
class C_Pdf extends CI_Controller {
private $params = array();
function __construct() {
parent::__construct();
$this->params['set_tag'] = array();
$this->params['set_css'] = array();
$this->params['set_js'] = array();
$this->params['title_auto'] = true;
$this->params['title'] = '';
}
public function index(){
//this data will be passed on to the view
$data['the_content']='mPDF and CodeIgniter are cool!';
$data['other']="siema heniu cos przeszlo";
//load the view, pass the variable and do not show it but "save" the output into $html variable
$this->load->view('common/default_header',$this->params);
$html=$this->load->view('reservation/complete', $data,true);
$this->load->view('common/default_footer');
//this the the PDF filename that user will get to download
//load mPDF library
$this->load->library('m_pdf');
//actually, you can pass mPDF parameter on this load() function
$pdf = $this->m_pdf->load();
//generate the PDF!
$pdf->WriteHTML($html);
//offer it to user via browser download! (The PDF won't be saved on your server HDD)
$pdf->Output();
}
}?>
我想从其他 View 添加页脚和页眉。
最佳答案
只需将页眉和页脚模板预取到变量中,然后将它们解析后的字符串传递给主视图,如下所示:
$data['header'] = $this->load->view('common/default_header',$this->params, true);
$data['footer'] = $this->load->view('common/default_footer', true);
$html = $this->load->view('reservation/complete', $data, true);
注意第三个参数为true,这样您就可以在字符串中获取 View ,而不是将其发送到输出(最常见的是客户端浏览器)。
然后在您的主模板中,将 $header 和 $footer 变量放在您需要的任何位置。
关于php - 如何将多个 View 加载到 mpdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31296487/
Mpdf 中的以下两个函数在所有页面中添加页眉和页脚。 设置HTMLHeader()SetHTMLFooter() 但是,有人可以帮我从 pdf 的第一页删除页眉和页脚吗? 最佳答案 mPDF 有一个
我有这个问题/想拥有这个功能 我有一个类似于 #375 的问题而是,我的表的功能主要与文档中预期的一样。唯一不能理解的是,我的表头会从一页开始,然后对于一个长表,或者如果它只是延伸到页尾,表数据将移动
我使用的是带有 yii2 的 mpdf 8.1,用于 pdf 报告下载的 php 版本是 5.6.40。它在本地环境中运行良好。但是在具有相同 php 版本的实时服务器中找不到类 mpdf。 mpdf
我正在尝试通过按 eventView.php 中的打印按钮将 html View eventView.php 导出并下载到 pdf,使用 mPDF。即使加载速度很慢,我现在也可以转换为 pdf,但现在
不幸的是,我无法自己简单地测试它。我在这里查看了文档: https://mpdf.github.io/css-stylesheets/supported-css.html 它没有列出任何关于伪类的信息
我目前使用的是 mpdf 6.1,我想切换到 7。但是我找不到没有 Composer 的方法来安装它。是否有完整的软件包可以在我的本地主机上下载、解压缩和测试? 最佳答案 好吧,我花了几天的时间寻找方
4 月份在工作服务器上开始时,我们受到了这个问题的困扰。在客户报告 PDF 不再显示图像之前,我们的应用程序一切正常。 我们的 PDF 是首先通过 HTML 渲染生成的。当显示 HTML 渲染时,图像
使用 PHP 5.6 在 WAMP 堆栈上开发,然后转移到 LAMP 7.1.5一切正常,除了 mPDF 6.1.0 提供以下内容: Warning: A non-numeric value enco
对于我通过 Composer 安装了 mpdf 6 的项目 composer require mpdf/mpdf 它工作得很好,但库本身是我整个项目的十倍。有没有我可以删除的文件?例如,我什么时候需要
$style='@page *{ margin-top: 0cm; margin-bottom: 0cm; margin-left: 0cm; margin-right: 0cm; }'; $html
我想将 mPDF 包含到我的 WordPress 插件中以启用某些导出为 PDF 的功能。然而,mPDF 文件非常大,约为 98mb。 是否只有我可以包含的特定文件才能保留导出为 HTML 并保持格式
它不会在 pdf 中显示 ite1 值。为什么?您能纠正我的错误吗? WriteHTML('Hello World'); $html1 = ' Module De
我想将 mPDF 包含到我的 WordPress 插件中以启用某些导出为 PDF 的功能。然而,mPDF 文件非常大,约为 98mb。 是否只有我可以包含的特定文件才能保留导出为 HTML 并保持格式
我正在使用 mPDF 7.x 版并尝试遵循此文档: https://mpdf.github.io/fonts-languages/fonts-in-mpdf-7-x.html 我只是无法让它工作。没有
您好,我正在使用 mpdf 生成 pdf。现在我面临 html 中表格边框的问题。我在 html 中有以下表格样式 Test header Test he
@page :last { background: rgb(167,0,51); } 我需要为 PDF 的最后一页添加背景,但它不起作用。只有第一页得到 bg 但不是最后一页。有什么解决办法吗? 引
我正在使用 mpdf在 Laravel 和 this package 版本 4.0 问题是我有一个不同高度的问题列表,其中有 4 个选项,我不知道每个 div 标签的确切和大致高度,其中有哪些问题和答
我需要使用 mPDF 生成发票,它们都有页眉、页脚和必须覆盖整个页面的相同背景图像。 我在网上看到了其他解决方案,但没有一个对我有用。 这是几次尝试,都导致失败(图像不显示、50* 错误或使用图像时图
我正在使用 mpdf 库,但是我认为在下载文件时更改下载文件的名称会相当简单,文档说明如下: WriteHTML('Hallo World'); $mpdf->Output('filename.pdf
注:mpdf 6.0 你好, 我正在尝试使用 mpdf 生成 pdf,它需要元素的精确定位以便以后打印。元素将从给定页面的最左上角开始绘制,即不应有隐式填充、边距或其他可能影响元素在正文中位置的内容。
我是一名优秀的程序员,十分优秀!