8

我正在使用 Snappy Bundle 和 Symfony 2.1。

我有一些在此捆绑包的文档中没有找到的问题:

  • 如何设置方向?
  • 有没有办法显示页码?

这是我的 config.yml 包:

knp_snappy:
    pdf:
        enabled:    true
        binary:     /home/wkhtmltopdf-i386
        options:    []

这是我生成pdf的控制器之一:

public function exampleAction() {
    $html = $this->renderView('MyBundle:Example:test.pdf.twig', $this->param);  
    return new Response($this->get('knp_snappy.pdf')->getOutputFromHtml($html),200, array(
    'Content-Type'          => 'application/pdf',
    'Content-Disposition'   => 'attachment; filename="Test.pdf"'));

} 

非常感谢你的帮助!

4

1 回答 1

24
$pdf = $this->get('knp_snappy.pdf')->getOutputFromHtml($html,
                                   array('orientation'=>'Landscape',
                                         'default-header'=>true));
于 2012-11-08T19:16:48.313 回答