html2pdf / html2pdf-2image
transfer html to pdf or image
Installs: 47
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:php7-extension
Requires
- php: >=7.0.0
This package is not auto-updated.
Last update: 2024-05-07 08:02:01 UTC
README
Transfer html to pdf or image using htmltopdf.
Requirements
PHP7
###htmltopdf
cd /tmp
wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz && rm wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
ln -s -T /tmp/wkhtmltox/bin/wkhtmltopdf /usr/local/bin/wkhtmltopdf && \
chmod a+x /usr/local/bin/wkhtmltopdf && \
ln -s -T /tmp/wkhtmltox/bin/wkhtmltoimage /usr/local/bin/wkhtmltoimage && \
chmod a+x /usr/local/bin/wkhtmltoimage
Check and get help by wkhtmltopdf -h
or wkhtmltoimage -h
More information to see: https://wkhtmltopdf.org/
Install
composer require html2pdf/html2pdf-2image
Quick Start and Examples
require __DIR__ . '/vendor/autoload.php';
use \Html\Html2Pdf;
use \Html\Html2Image;
$html = '<html><head><title>export</title>......';
// or
// $html = file_get_contents('http://google.com');
// Pdf
$generator = new Html2Pdf('/usr/local/bin/wkhtmltopdf');
$options = ['header'=>'Centered header text','footer'=>'Left aligned footer text'];
$generator->getOutputFromHtml($html, $options)
// Image
$generator = new Html2Image('/usr/local/bin/wkhtmltoimage');
$options = ['format'=>'png','width'=>'300','height'=>'1000'];
$generator->getOutputFromHtml($html, $options)