如何使用KnpSnappyBundle设置orientation = landscape?

Rev*_*air 7 wkhtmltopdf symfony

我正在使用Snappy Bundle和Symfony 2.1.

我有一些问题,我在这个包的文档中没有找到:

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

这是我的bundle的config.yml:

knp_snappy:
    pdf:
        enabled:    true
        binary:     /home/wkhtmltopdf-i386
        options:    []
Run Code Online (Sandbox Code Playgroud)

这是我的一个生成pdf的Controller:

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"'));

} 
Run Code Online (Sandbox Code Playgroud)

非常感谢你的帮助!

jam*_*s_t 20

$pdf = $this->get('knp_snappy.pdf')->getOutputFromHtml($html,
                                   array('orientation'=>'Landscape',
                                         'default-header'=>true));
Run Code Online (Sandbox Code Playgroud)

  • 你把参数放在错误的位置,它应该是这样的:`return new Response($ this-> get('knp_snappy.pdf') - > getOutputFromHtml($ html,array('orientation'=>'Landscape) ','default-header'=> true)),200,array('Content-Type'=>'application/pdf','Content-Disposition'=>'attachment; filename ="Test.pdf"')) );` (3认同)