1. Go to this page and download the library: Download frengky/php-wkhtmltox 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/ */
frengky / php-wkhtmltox example snippets
use Frengky\WkHtml\PDF;
$htmlString = 'Hello, <strong>World</strong>!'
$outputPath = PDF::fromHtml($contents)
->set('--page-size', 'A4') // the args to wkhtmltopdf
->set('--orientation', 'Portrait')
->saveAs('storage/files/test-success.pdf');
if ($result) {
echo "Generated pdf output file path: " . $outputPath;
}
$htmlSource = Psr7\stream_for('Hello, <strong>World</strong>!');
$retval = PDF::fromHtml($htmlSource)
->set('--page-size', 'A4') // the args to wkhtmltopdf
->set('--orientation', 'Portrait')
->render(function(StreamInterface $output) {
// Do something with the stream
file_put_contents('output.pdf', $output->getContents());
});
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.