dev-master 2017-07-05 12:52 UTC


This is wrapper on node library .

Simple example:

use issidorov\htmlPdf\Pdf;

$pdf = Pdf::fromHtmlFile($htmlFileName);


Install for Ubuntu:

$ sudo apt install composer npm nodejs-legacy libfontconfig
$ sudo npm install -g html-pdf
$ composer require issidorov/html-pdf


Create instance of class:

$pdf = Pdf::fromHtmlFile($htmlFileName);
// OR
$pdf = Pdf::fromHtmlContent($html);

Run convert to pdf file:

// Write to concrete file

// Write to /tmp directory
$pdfFileName = $pdf->writeToTmpFile();

Set CSS and Images base directory:

$pdf->setBasePath(__DIR__ . '/assets');

Set page size:

$pdf->setSize('100mm', '50mm');
// OR

Set and remove border sizes:

// Set border
$pdf->setBoder('20mm', '20mm', '20mm', '20mm');

// Clean border

Set page headers:


Set page footers:


Set page header content on first page:

$pdf->setHeaderContent('<div>First page</div>', 'first');