【问题标题】:Symfony2 Pdf generationSymfony2 Pdf生成
【发布时间】:2015-11-29 02:01:25
【问题描述】:

我需要生成一个 PDF,我使用的是 SpreadPdfGeneratorBundle,问题是这个包使用了我的 webHosting “ex2”禁用的“proc_open”功能,我联系了他们,他们告诉我他们无法启用这个功能。 PDF 生成在语言环境中运行良好。这是代码:

$html= $request->get('lettreheader');
$request->get('lettreContent').$request->get('lettreFooter');
/*$html = $this->renderView('GrcRelanceBundle:Default:lettreRelance.html.twig');*/
$pdfGenerator = $this->get('spraed.pdf.generator');
$pdfGenerator->generatePDF($html);
return  new Response($pdfGenerator->generatePDF($html),
    200,
    array(
        'Content-Type' => 'application/pdf',
        'Content-Disposition' => "inline; filename='Relance client.pdf'"
    )
);

错误信息是:

警告:proc_open() 出于安全原因已被禁用(500 内部服务器错误)

感谢您的帮助。

【问题讨论】:

    标签: symfony pdf pdf-generation wkhtmltopdf proc-open


    【解决方案1】:

    我最近花了很多时间研究 PDF 生成的解决方案。我和你有同样的问题:我无法控制服务器上启用的内容,也无法在服务器上执行二进制文件。

    我找到的最佳解决方案是 TCPDF,因为它只是 PHP。有一个 Symfony 包可以启用它:

    https://github.com/whiteoctober/WhiteOctoberTCPDFBundle

    我不知道它与SpreadPdfGeneratorBundle 相比如何,生成有时有点棘手,尤其是对于部分 CSS 支持,但我仍然能够在服务器上正确生成 PDF。

    【讨论】:

    • 拜托,你有任何文档吗,因为github中的文档不够用,我需要从视图中生成pdf并将其保存在一个文件夹中。
    • Bundle github上有非常view doc,但是这个bundle只是集成TCPDF的一种方式。对于我的开发,我使用了这里的示例:tcpdf.org/examples.php
    猜你喜欢
    • 2023-03-08
    • 2014-03-28
    • 2015-05-15
    • 1970-01-01
    • 2014-09-29
    • 1970-01-01
    • 2013-11-22
    • 1970-01-01
    • 2011-05-29
    相关资源
    最近更新 更多