Wkhtml2pdf Outputfilter

Skip to end of metadata
Go to start of metadata

The wkhtml2pdf - outputfilter is a Zend_Controller_Plugin which allows you to output any html as PDF. For the conversion we use http://code.google.com/p/wkhtmltopdf/ , which uses WebKit to render the HTML and is also able to render CSS(3) and Javascript (eg. Highcharts, Google Charts API, ... )

How to use it

First of all you need wkhtml2pdf, you can download it here: http://code.google.com/p/wkhtmltopdf/

Then checkout (SVN) or download the code from here: http://www.pimcore.org/svn/labs/trunk/wkhtml2pdf/

Now you can register the outputfilter in your action, for example: 

<?php

class PrintController extends Website_Controller_Action {

	public function defaultAction () {

        if(!$this->editmode) {
            $front = Zend_Controller_Front::getInstance();
            $front->registerPlugin(new Website_Controller_Plugin_Wkhtmltopdf(array(
                "options" => array( // configuration for wkhtmltopdf ( see http://madalgo.au.dk/~jakobt/wkhtmltopdf-0.9.9-doc.html )
                    "--disable-smart-shrinking",
                    "--print-media-type",
                    "--margin-left" => "0",
                    "--margin-top" => "0",
                    "--margin-bottom" => "0",
                    "--margin-right" => "0",
                    "--no-outline"
                ),
                "bin" => "/usr/local/bin/wkhtmltopdf-amd64" // path to the wkhtmltopdf binary (default is /usr/bin/wkhtmltopdf)
            )), 700);
        }



    }
}

Get the source-code

You can checkout the source-code from the SVN - labs repository

http://www.pimcore.org/svn/labs/trunk/wkhtml2pdf/

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. May 09, 2011

    Nikolaus Flamann says:

    If you are using LESS change the last Parameter in a value over 799 (Stackindex)

    If you are using LESS change the last Parameter in a value over 799 (Stackindex)