dpsoft/php-html-to-pdf

Convert any url or html to pdf/image using google-chrome or chromium-browser

v1.1 2018-08-18 07:06 UTC

This package is auto-updated.

Last update: 2024-10-16 04:48:37 UTC


README

License: GPL v2

Convert any url or html to pdf/image using google-chrome or chromium-browser

Installation

$ composer require dpsoft/php-html-to-pdf

Requirement

This package uses google-chrome/chromium-browser. for example install chromium-browser on linux ubuntu:

~ sudo apt install chromium-browser

To verify requirement, run following test from package folder:

~ composer test

Implementation

Use url or html file to export:

require "vendor/autoload.php";

use Dpsoft\HtmlToPdf\Converter;

$converter = new Converter();

// export to pdf
$convertor->setUrl('http://google.com')->toPdf('pdf/file/name.pdf');

// or export to png
$convertor->setUrl('http://google.com')->toPng('png/file/name.png');

// you can set window size for png export
$convertor->setUrl('http://google.com')->setWindow(1280,960)->toPng('png/file/name.png');

Test

Run test:

~ composer test