Skip to content

Projects · FZPure suite

FZPureHTML

HTML to PDF in pure PHP. Write your document in HTML with the bundled stylesheet, call one function, get the PDF. Two files to copy to your server.

Try the demo Code on GitHub Download the latest release

  • Licence MIT
  • Documentation in English and Italian

The problem

HTML-to-PDF converters usually try to understand all of CSS, and the result is a surprise. They often need a headless browser or heavy libraries on the server, too.

The idea

FZPureHTML does the opposite: it ships one stylesheet containing only what the converter renders well. The browser uses it for the preview, the converter reads the very same stylesheet to produce the PDF. What you see on screen and what you get in the PDF match, line breaks included.

At a glance

  • No external libraries, no programs to install, no Composer.
  • Browser preview identical to the PDF, line breaks included.
  • Headers, footers and page numbers.
  • Real TrueType fonts, embedded in the PDF.

How to use it

require 'FZPureHTML.php';
$pdf = FZPureHTML::convertFile('document.html');
FZPureHTML::output($pdf, 'inline', 'document.pdf');

Requirements: PHP 8.1+ with dom, mbstring, zlib. TrueType fonts (e.g. Liberation).

Full example: Sample HTML document · Generated PDF

Installation, configuration and the full reference are in the README on GitHub.

Support the project

FZPureHTML is free and open source. If you find it useful, you can buy me a coffee: it is a simple way to support its development.

☕ Buy me a coffee

Same family

FZPure suite

FZPureDOCX

DOCX and PDF documents from Word templates.

A small PHP server that fills Word templates, replacing placeholders with text, HTML, tables and checkboxes, and returns DOCX or PDF.

PHP · MIT · IT/EN

Details Code on GitHub

Follow the projects

New releases, development notes and what I learn along the way.

Follow on GitHub Newsletter (Italian)