dompdf/dompdf
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
masterminds/html5 | 2.9.0 | - | MIT | prod | |
phenx/php-font-lib | 0.5.6 | - | LGPL-2.1-or-later | prod | 1 |
phenx/php-svg-lib | 0.5.4 | - | LGPL-3.0-or-later | prod | 1 |
Dompdf is a powerful tool that operates as an HTML to PDF converter. At its core, it's a style-driven rendering engine, capable of interpreting and implementing CSS 2.1. Not only does it support most presentational HTML attributes, but it also reads external stylesheets, inline style tags, and CSS rules for individual HTML elements. Its exceptional functionality, written in PHP, allows for a wide array of CSS 2.1 properties, including @import, @media, and @page rules.
You can utilize Dompdf in just a few easy steps. Start by installing it with Composer using the command composer require dompdf/dompdf
. Then, you'll have to load the Composer autoload file in your project.
require 'vendor/autoload.php';
The core Dompdf class can be utilized to convert your HTML content into a PDF.
use Dompdf\Dompdf;
$dompdf = new Dompdf();
$dompdf->loadHtml('hello world');
$dompdf->setPaper('A4', 'landscape');
$dompdf->render();
$dompdf->stream();
Also, you can set options either during Dompdf instantiation or at run time.
use Dompdf\Dompdf;
use Dompdf\Options;
$options = new Options();
$options->set('defaultFont', 'Courier');
$dompdf = new Dompdf($options);
These steps should assist you in exploiting Dompdf's powerful functionality to generate PDFs from HTML content.
You can find the comprehensive documentation for Dompdf here. In addition to explaining various features and functions of the package, it also offers insight on requirements, recommendations, and known limitations. It contains all the necessary information to use, troubleshoot, and understand the workings of the Dompdf package, making it helpful for all users, including newcomers and experienced developers.