Download the PHP package yii2tech/html2pdf without Composer
On this page you can find all versions of the php package yii2tech/html2pdf. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Rated 3.00 based on 2 reviews
Informations about the package html2pdf
HTML to PDF conversion extension for Yii2
This extension provides basic support for HTML to PDF and PHP to PDF conversion.
For license information check the LICENSE-file.
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json.
Note: you'll have to install software for the actual HTML to PDF conversion separately, depending on the particular converter, you would like to use.
Usage
This extension provides support for HTML to PDF and PHP to PDF conversion. It allows composition of the PDF files from HTML and via rendering PHP templates.
Extension functionality is aggregated into \yii2tech\html2pdf\Manager
application component.
Application configuration example:
For the simple conversion you can use \yii2tech\html2pdf\Manager::convert()
and \yii2tech\html2pdf\Manager::convertFile()
methods:
The actual conversion result determined by particular converter used.
You may use \yii2tech\html2pdf\Manager::$converter
property for the converter setup.
Several built-in converters are provided:
- wkhtmltopdf utility for the conversion.
- dompdf library for the conversion.
- mpdf library for the conversion.
- TCPDF library for the conversion.
- yii2tech\html2pdf\converters\Callback - uses a custom PHP callback for the conversion.
Heads up! Most of the provided converters require additional software been installed, which is not provided by his extension by default. You'll have to install it manually, once you decide, which converter you will use. Please refer to the particular converter class for more details.
You may specify conversion options via second argument of the convert()
or convertFile()
method:
You may setup default conversion options at the \yii2tech\html2pdf\Manager
level:
Note: the actual list of available conversion options depends on the particular converter to be used.
Template usage
You may create PDF files rendering PHP templates (view files), which composes HTML output.
Such files are processed as regular view files, allowing passing params and layout wrapping.
Method \yii2tech\html2pdf\Manager::render()
used for this:
You may use a shared layout for the templates, which can be setup via \yii2tech\html2pdf\Manager::$layout
.
During each rendering view is working in context of \yii2tech\html2pdf\Template
object, which can be used to adjust
layout or PDF conversion options inside view file: