PHP code example of spiritix / php-chrome-html2pdf

1. Go to this page and download the library: Download spiritix/php-chrome-html2pdf 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/ */

    

spiritix / php-chrome-html2pdf example snippets


use Spiritix\Html2Pdf\Converter;
use Spiritix\Html2Pdf\Input\UrlInput;
use Spiritix\Html2Pdf\Output\DownloadOutput;

$input = new UrlInput();
$input->setUrl('https://www.google.com');

$converter = new Converter($input, new DownloadOutput());

$converter->setOption('landscape', true);

$converter->setOptions([
    'printBackground' => true,
    'displayHeaderFooter' => true,
    'headerTemplate' => '<p>I am a header</p>',
]);

$output = $converter->convert();
$output->download('google.pdf');