8

Symfony 2.1 と共に Snappy Bundle を使用しています。

このバンドルのドキュメントで見つけられなかった質問があります:

  • 向きを設定するには?
  • ページ番号を表示する方法はありますか?

バンドルの config.yml は次のとおりです。

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

これは、pdfを生成するための私のコントローラの1つです:

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 に答える