1. Go to this page and download the library: Download heyday/silverstripe-wkhtml library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
heyday / silverstripe-wkhtml example snippets
use Heyday\SilverStripe\WkHtml;
use SilverStripe\Core\Injector\Injector;
$generator = WkHtml\Generator::create(
// Use Injector->get(Pdf::class) if you don't need to modify options
// Use Injector->create() to create a transient service for modifications (e.g. setOption)
// Using Injector->get() and making changes will cause changes to be made for all uses of get(Pdf::class) for the entire request
Injector::inst()->create(\Knp\Snappy\Pdf::class),
WkHtml\Input\Url::create('/'),
WkHtml\Output\Browser::create('test.pdf', 'application/pdf')
);
return $generator->process();
\Heyday\SilverStripe\WkHtml\Input\Request::create(
// Controller::curr()->getRequest() is also an option
Injector::inst()->get(\SilverStripe\Control\HTTPRequest::class)
);
\Heyday\SilverStripe\WkHtml\Input\Request::create(
Injector::inst()->get(\SilverStripe\Control\HTTPRequest::class),
new Session([
'arg' => 'value',
])
);