Nice (and thanks!). Have you considered writing a Yii extension wrapper for it at some point or should I put that on my list of things to do when I get the chance?
I tried to make this class independent of Yii. It is so simple that i don’t think, we need another wrapper around it to use it in Yii. Actually i’m already using it in my Yii projects. In my opinion not every third party library needs to be wrapped up in an extension.
Or let me ask the other way round: What should a wrapper class add what the original class doesn’t already provide?
From what I remember from when I looked at WkHtmlToPdf a few years ago, there was a way to set headers/footers. Maybe we could set that on an app basis in an extension?
Good point on the library stuff. A counter point though is that people who don’t know that much about PDF creation from HTML may look through the extension section and never end up using your gem, because they don’t find it. Wouldn’t it help raise the visibility of your library (and thus help people more often) to make it an extension?
<?php
$options=array(
'footer-html'=>'footer.html',
'header-html'=>'header.html',
));
// Then either set it for every page:
$pdf->setPageOptions($options);
// Or only for a specific page:
$pdf->addPage('page.html', $options);
See wkhtmltopdf -H for more options.
I agree that an extension might help to increase popularity. I’m just not sure if this really makes sense: This class is not related to Yii at all. It’s rather a standalone class which you can easily integrate into Yii. And for now the home is the github page. I don’t want to maintain two downloads for this class. But let me think about it, maybe i change my mind …
What a wrapper class could do: Add getter/setter support through CComponent and wrap up errors in exceptions. Let’s see.
If you add a page from URL you don’t have to include a CSS file - wkhtmltopdf will fetch the HTML and whatever CSS file is defined inside the page. But you can also set a static CSS file like this:
Then you need to do some manual debugging: You could echo the $command in line 287 in WkHtmlToPdf.php, in the createPdf() method right after the $command = $this->getCommand($fileName); line.
Personally i’ve never used a TOC, so it’s very well possible that there’s still a bug here.