我想使用dompdf生成pdf文档。我使用DOMPDModule得到了带有以下代码的pdf响应。但我的问题是,我如何将变量传递到phtml文件以在pdf文件上打印我的代码如下
use DOMPDFModule'View'Model'PdfModel;
...
..
public function printAction()
{
$campaignsList=$this->getcampaignTable()->getCampaignList();
$model = new PdfModel();
$model->setOption('paperSize', 'a4');
$model->setOption('paperOrientation', 'landscape');
return $model;
}
如何在print.phtml文件中打印$campaignList数组
提前感谢
我不能100%确定你在问什么,你可以在不涉及视图的情况下完全在你的操作中创建PDF(假设这就是你引用phtml文件时的意思)。
使用DOMpdf:生成PDF的一些示例代码
<?php
// Create a new DOMPDF object
$dompdf = new 'DOMPDF();
// Set the paper size to A4
$dompdf->set_paper('A4');
// Load the HTML
$dompdf->load_html($html);
// Render the PDF
$dompdf->render();
// Set the PDF Author
$dompdf->add_info('Author', 'I am the Author');
// Set the PDF Title
$dompdf->add_info('Title', 'My PDF Title');
/**
* 'Attachment' => 1 or 0 - if 1, force the browser to open a
* download dialog, on (1) by default
*/
$dompdf->stream($name,array('Attachment'=>1));
?>
记录的用法-DOMPDF LINK