Php 在symfony 2.3中创建pdf*
我已在symfony 2.3中搜索创建pdf文件,但未成功。我有两包Php 在symfony 2.3中创建pdf*,php,symfony,pdf,wkhtmltopdf,symfony-2.3,Php,Symfony,Pdf,Wkhtmltopdf,Symfony 2.3,我已在symfony 2.3中搜索创建pdf文件,但未成功。我有两包 另一个是 我的任务就是点击下载pdf文件。为此,我在html.twig中给出了类似的链接 <a href="{{path('route name')}}">Download file</a> 然后出错了 退出状态代码“1”表示出现了问题:stderr:“ 系统找不到指定的路径 安装是否需要wkpdftohtml如果需要,则如何在基于共享的主机上安装 在psliwa/PHPdf中,我阅读了以下示例:
<a href="{{path('route name')}}">Download file</a>
然后出错了
退出状态代码“1”表示出现了问题:stderr:“
系统找不到指定的路径
安装是否需要wkpdftohtml
如果需要,则如何在基于共享的主机上安装
在psliwa/PHPdf中,我阅读了以下示例:
$format=$this->get('request')->get('u format');
更改为$format='pdf';
,那么它将显示简单的html文件。无法理解为完成任务我应该做什么…是。对于Knp Snappy Bundle,wkhtmltopdf是必需的,您需要在config.yml中正确配置它
knp_snappy:
pdf:
enabled: true
binary: /usr/local/bin/wkhtmltopdf #path to wkhtmltopdf binary
options: []
这是使用psliwa/PHPPdf的实时共享主机环境中控制器的摘录:
$facade = $this->get('ps_pdf.facade');
$response = new Response();
$this->render('ManaClientBundle:Contact:roster.html.twig', array(
'date' => $found['latestDate'],
'center' => $location,
'roster' => $found['contactSet'],
), $response);
$date = new \DateTime($found['latestDate']);
$filename = str_replace(' ', '', $location) . date_format($date, '_Ymd') . '.pdf';
$xml = $response->getContent();
$stylesheet = $this->renderView('ManaClientBundle:Contact:contact.xml.twig', array());
$content = $facade->render($xml, $stylesheet);
return new Response($content, 200, array
('content-type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename=' . $filename
));
将二进制文件从下载到文件夹或bin文件夹,并在配置文件中给出路径。对于某些功能,您可能需要xvfb。
$facade = $this->get('ps_pdf.facade');
$response = new Response();
$this->render('ManaClientBundle:Contact:roster.html.twig', array(
'date' => $found['latestDate'],
'center' => $location,
'roster' => $found['contactSet'],
), $response);
$date = new \DateTime($found['latestDate']);
$filename = str_replace(' ', '', $location) . date_format($date, '_Ymd') . '.pdf';
$xml = $response->getContent();
$stylesheet = $this->renderView('ManaClientBundle:Contact:contact.xml.twig', array());
$content = $facade->render($xml, $stylesheet);
return new Response($content, 200, array
('content-type' => 'application/pdf',
'Content-Disposition' => 'attachment; filename=' . $filename
));