Using external class

class page_pdf extends Page{
public function init() {
require dirname(FILE).’…/…/…/libs/src/Knp/Snappy/GeneratorInterface.php’;
require dirname(FILE).’…/…/…/libs/src/Knp/Snappy/AbstractGenerator.php’;
require dirname(FILE).’…/…/…/libs/src/Knp/Snappy/Image.php’;

    require dirname(__FILE__).'../../../libs/src/Knp/Snappy/Pdf.php';
    $snappy = new Pdf('/usr/local/bin/wkhtmltopdf');
    $snappy->generateFromHtml('<h1>Bill</h1><p>You owe me money dude.</p>', dirname(__FILE__).'../../logs/bill-123.pdf');


Error :
Exception_PathFinder: Class is not defined in file


the Pdf Class is using namespaces. It should work like that:

<?php class page_pdf extends Page{ public function init() { parent::init(); require dirname(__FILE__).'/../libs/src/Knp/Snappy/GeneratorInterface.php'; require dirname(__FILE__).'/../libs/src/Knp/Snappy/AbstractGenerator.php'; require dirname(__FILE__).'/../libs/src/Knp/Snappy/Image.php'; require dirname(__FILE__).'/../libs/src/Knp/Snappy/Pdf.php'; $snappy = new \Knp\Snappy\Pdf('/usr/local/bin/wkhtmltopdf'); $snappy->generateFromHtml('


You owe me money dude.

', dirname(__FILE__).'../../logs/bill-123.pdf'); } } I changed some paths and corrected some typos e.g. FILE to __FILE___. Sincerly, Phil

Thank you,
for : new \Knp\Snappy\Pdf


I have created a ATK4 wrapper around wkhtmltopdf library, by using quite old version of this class:

It works fine for about a year in production system.
There are some bugs in it, but it’s not my class bugs, but bugs in wkhtmltopdf library as such.
For example this one with font sizes: