1. Go to this page and download the library: Download spacetab-io/wkhtmltopdf 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/ */
spacetab-io / wkhtmltopdf example snippets
use Amp\Loop;
use Spacetab\WkHTML;
Loop::run(static fn() =>
yield WkHTML\ToPDF::new()->fromHtml('<p>hello world</p>')->asFile('hi.pdf')
);
use Amp\Loop;
use Spacetab\WkHTML;
Loop::run(static fn() =>
yield WkHTML\ToPDF::new()->fromUrl('https://google.com')->asFile('google.pdf')
);
use Amp\Loop;
use Spacetab\WkHTML;
use Spacetab\WkHTML\OptionBuilder;
Loop::run(static function () {
$option = new OptionBuilder\PDF();
$option->addGrayscale();
yield WkHTML\ToPDF::new()->fromUrl('https://google.com')->asFile('google.pdf');
});
use Amp\Loop;
use Spacetab\WkHTML;
use Spacetab\WkHTML\OptionBuilder;
use Spacetab\WkHTML\OptionBuilder\OptionBuilderInterface;
use Spacetab\WkHTML\OptionGroup\OptionGroupInterface;
Loop::run(static function () {
$pdf = new WkHTML\ToPDF(new class implements OptionGroupInterface {
public function __invoke(): OptionBuilderInterface {
$option = new OptionBuilder\PDF();
$option->addGrayscale();
return $option;
}
});
yield $pdf->fromUrl('https://google.com')->asFile('google.pdf');
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.