PHP code example of eprofos / php-wkhtmltopdf

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

    

eprofos / php-wkhtmltopdf example snippets


use Eprofos\PhpWkhtmltopdf\WKHtmlToPdf;

$wkhtmltopdf = new WKHtmlToPdf('/path/to/wkhtmltopdf');

$wkhtmltopdf->addPage('https://example.com')
             ->setPageSize('A4')
             ->setOrientation('Portrait')
             ->setGrayscale(true)
             ->setZoom(0.75)
             ->generate('output.pdf');

__construct(string $binary = '')

addPage(string $content, array $options = []): self
addCover(string $content, array $options = []): self
addToc(array $options = []): self

setOption(string $name, ?string $value = null): self
setOptions(array $options): self
setHeader(string $html, array $options = []): self
setFooter(string $html, array $options = []): self
setMargins(string $top, string $right, string $bottom, string $left): self
setOrientation(string $orientation): self
setPageSize(string $size): self
setZoom(float $zoom): self
setDpi(int $dpi): self
setGrayscale(bool $grayscale = false): self
setLowQuality(bool $lowQuality = true): self

generate(string $output): string
bash
composer