The main method to use is
output
.'Hi, I have a problem with downloading multiple PDF's at single instance. So this page should be converted into a PDF file using HTML2PDF class as given. HTML2PDF Pilot (doc2pdf.exe). HTML2PDF Pilot is a tool for converting HTML and plain text documents to PDF files, maintaining the format of the original document. It has options for PDF format and security. It integrates with Internet Explorer, so you can convert a document right in the browser window, with no need to save to your disk.
![Pdf Pdf](http://i1-win.softpedia-static.com/screenshots/CHMPDF-Pilot_1.png)
It takes two not required parameters.
Parameters
Parameter | Default | Description |
---|---|---|
$name | document.pdf | The name of the file when saved. Note that special characters are removed and blanks characters are replaced with the underscore character. |
$dest | I | Destination where to send the document. It can take one of the following values:
|
Examples
Send PDF to browser without specifying a name
Send the PDF document in browser with a specific name
Forcing the download of PDF via web browser, with a specific name
Write the contents of a PDF file on the server
Retrieve the contents of the PDF and then do whatever you want
Then, you can send it by email, using a Bin Attachment document.
Composer and Packagist
You must use Composer to install Html2Pdf.
If you do not know what is Composer, you are a few years late...
It is used by all the modern PHP applications (Magento2, Drupal, EasyPlatform, Symfony, ...).
You can read all the pages on https://getcomposer.org/doc/
You can find all the available packages on https://packagist.org/
For example, you can find Html2Pdf: https://packagist.org/packages/spipu/html2pdf
You have to commit the
composer.json
and composer.lock
files, but never commit the vendor
folder.If you do not understand why, it is because you have not read the Composer documentation...
Install
You have just to launch the following command on the root folder of your project:
First Test
Here is a HelloWorld example, that you can put on the root folder of your project.
Html2Pdf use the PSR-4 autoloader of Composer. You have just to require it. Never require manually the classes, it will not work at all. You must use the Composer functionnalities.
Then, you have just to use the main class
SpipuHtml2PdfHtml2Pdf
, with the 2 main methods writeHTML
and output
.And on production ?
You have not to install composer on your production server.
You have to install composer only on your dev environement. Composer is a dev tool.
To deliver you app on a server, you have to (on you dev environement) :
- Git clone the tag/branch that you want to deliver
- Launch the command
composer install --no-dev
- Remove the useless files (like the
.git
folder) - Zip all
That's all, you have a beautifull package that can be deliver on a server !