https://github.com/biaoqianwo/php-htmltopdf-htmltoimage
transfer html to pdf or image
https://github.com/biaoqianwo/php-htmltopdf-htmltoimage
html2image html2pdf htmltoimage htmltopdf php wkhtmltopdf
Last synced: 6 months ago
JSON representation
transfer html to pdf or image
- Host: GitHub
- URL: https://github.com/biaoqianwo/php-htmltopdf-htmltoimage
- Owner: biaoqianwo
- License: mit
- Created: 2017-08-30T06:24:39.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-08-30T09:35:07.000Z (almost 9 years ago)
- Last Synced: 2025-12-03T21:53:01.918Z (6 months ago)
- Topics: html2image, html2pdf, htmltoimage, htmltopdf, php, wkhtmltopdf
- Language: PHP
- Size: 12.7 KB
- Stars: 12
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# php-htmltopdf-htmltoimage
Transfer html to pdf or image using wkhtmltopdf.
## Requirements
### PHP7
###wkhtmltopdf
```
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 biaoqianwo/php-htmltopdf-htmltoimage`
## Quick Start and Examples
```
require __DIR__ . '/vendor/autoload.php';
use \Biaoqianwo\Html2Pdf\Html2Pdf;
use \Biaoqianwo\Html2Pdf\Html2Image;
$html = 'export......';
// 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)
```
## More
You can improve `getHeader()` 、 `getFooter()`.