Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set orientation = landscape using KnpSnappyBundle?

I'm using Snappy Bundle along with Symfony 2.1.

I have some question I did not find in the documentation of this bundle :

  • How to set the orientation ?
  • Is there a way to display page numbers ?

Here is my config.yml for the bundle :

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

Here is one of my Controller to generate a 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"'));

} 

Thanks a lot for your help!

like image 477
Reveclair Avatar asked Nov 08 '12 17:11

Reveclair


1 Answers

$pdf = $this->get('knp_snappy.pdf')->getOutputFromHtml($html,
                                   array('orientation'=>'Landscape',
                                         'default-header'=>true));
like image 177
james_t Avatar answered Nov 15 '22 07:11

james_t