Skip to content

Latest commit

 

History

History
49 lines (30 loc) · 1.39 KB

install.md

File metadata and controls

49 lines (30 loc) · 1.39 KB

How to Install Html2Pdf

back

Composer and Packagist

You have to use Composer to install Html2Pdf.

If you do not know what is Composer:

Install

You just have to launch the following command on the root folder of your project:

composer require spipu/html2pdf

If you do not want to use composer, you will need to:

  • manually clone the Html2pdf repository
  • manually clone all the repositories of the used dependencies
  • manage manually the PS4 autoload

But it is not the recommended way to install Html2Pdf. No help will be provided in this case.

First Test

Here is a HelloWorld example, that you can put on the root folder of your project.

require __DIR__.'/vendor/autoload.php';

use Spipu\Html2Pdf\Html2Pdf;

$html2pdf = new Html2Pdf();
$html2pdf->writeHTML('<h1>HelloWorld</h1>This is my first test');
$html2pdf->output();

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 functionalities.

Then, you have just to use the main class Spipu\Html2Pdf\Html2Pdf, with the 2 main methods writeHTML and output.

back