mvlabs / MvlabsSnappy

MvlabsSnappy is a ZF2/ZF3 module that allow easy to thumbnail, snapshot or PDF generation from a url or a html page using Snappy PHP (5.6+) wrapper for the wkhtmltopdf/wkhtmltoimage conversion utility.
MIT License
24 stars 10 forks source link

Options #5

Closed aurelien-w closed 10 years ago

aurelien-w commented 10 years ago

Hello,

I have not understand how to add options? For example:

<?php
return array(
    'mvlabs-snappy' => array(
        'pdf' => array(
           'binary'  => '/home/root/bin/wkhtmltopdf',
           'options' => array('--no-stop-slow-scripts'),
        ),   
        'image' => array(
            'binary'  => '/home/root/bin/wkhtmltoimage',
            'options' => array(),
         )
     )   
);

Don't work...

Thanks

drigani commented 10 years ago

Hi @aurelien-w , the correct way to set options is:


<?php
return array(
    'mvlabs-snappy' => array(
        'pdf' => array(
            'binary'  => '/home/root/bin/wkhtmltopdf',
            'options' => array(
                'javascript-delay'    => 2000,
                'no-stop-slow-scripts'=> true,
                'header-line'         => true,
                'footer-right'        => 'Pag. [page]/[topage]'
            ),
        ),
        'image' => array(
            'binary'  => '/home/root/bin/wkhtmltoimage',
            'options' => array(),
        )
    )
);

Or eventually:

   public function testPdfAction() {
      // ....
       $I_mvlabssnappyPdfService = $this->serviceLocator->get('mvlabssnappy.pdf.service');
       $I_mvlabssnappyPdfService->setOption('footer-right', 'Pag. [page]/[topage]');
      // ....
   }

Hope this helps. Cheers, Diego