phppdf/html-converter

Convert HTML and CSS into PDF documents on top of phppdf/phppdf

Maintainers

Package info

github.com/phppdf/html-converter

pkg:composer/phppdf/html-converter

Statistics

Installs: 1

Dependents: 0

Suggesters: 1

Stars: 0

Open Issues: 0

dev-master 2026-06-17 19:35 UTC

This package is auto-updated.

Last update: 2026-06-17 19:36:45 UTC


README

Convert HTML and CSS into PDF documents on top of phppdf/phppdf.

Requirements

  • PHP 8.4+
  • ext-dom
  • ext-libxml

Installation

composer require phppdf/html-converter

Documentation

The documentation can be found here: https://phppdf.github.io/html-converter/

Quick start

use PhpPdf\Html\HtmlConverter;
use PhpPdf\Output\PdfMemoryOutput;
use PhpPdf\Serialization\PdfDocumentSerializer;

$html = '<h1>Hello World</h1><p>Welcome to the PDF.</p>';

$document = HtmlConverter::fromHtml($html)->build();

$output = new PdfMemoryOutput();
(new PdfDocumentSerializer($output))->writeDocument($document);

header('Content-Type: application/pdf');
echo $output->getContent();

Because HtmlConverter::fromHtml() returns a plain PdfDocumentBuilder, you can prepend or append pages, add metadata/encryption/signatures, and apply compression before serialising.

Examples

Working examples live in the examples repository: https://github.com/phppdf/examples

Development

composer install
composer phpunit
composer phpunit:coverage
composer phpcs
composer phpstan