PHP code example of andrew72ru / web-to-print

1. Go to this page and download the library: Download andrew72ru/web-to-print 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/ */

    

andrew72ru / web-to-print example snippets


$logger = new \Psr\Log\NullLogger(); // Choose your Psr\Log\LoggerInterface implementation
$runner = new \Andrew72ru\Web2print\DriverRunner($logger, '/path/to/chromedriver');

$printer = new \Andrew72ru\Web2print\PrintToPdf($runner, $logger);
$result = $printer('https://google.com', asBas64: true); // You can get Base64 or binary string
\file_put_contents('google.pdf', \base64_decode($result));

$defaultArguments = ['--headless', '--run-all-compositor-stages-before-draw'];

$defaultParams = [
    'displayHeaderFooter' => false,
    'printBackground' => true,
    'marginTop' => 0,
    'marginBottom' => 0,
    'marginLeft' => 0,
    'marginRight' => 0,
];