Optional module · pdftoolkit/html-to-pdf 0.4.0

English · Français

Text spacing and first-line indentation

Version 0.4 adds word-spacing, letter-spacing and text-indent to the native PHP layout. These properties accept signed supported lengths and inherit their computed values. Spacing also accepts normal; indentation additionally accepts percentages. The usage guide describes their values and limits.

HTML source · Generator

p { word-spacing: 2px; letter-spacing: .05em; text-indent: 10%; }
p.tight { word-spacing: -1px; letter-spacing: -.02em; text-indent: -12px; }

The example uses explicitly supplied Noto Sans and includes positive/negative spacing, nonbreaking spaces, inherited em lengths, combining marks, ligatures and first-line indentation. It also exercises a paragraph continuing onto a new PDF page. Its source and font hashes are recorded in the generation manifest.

php -d memory_limit=512M examples/generate-text-spacing.php _build/text-spacing
node tools/validate_text_spacing.cjs _build/text-spacing/browser
python tools/validate_text_spacing.py --pdf _build/text-spacing/text-spacing.pdf \
  --manifest _build/text-spacing/manifest.json \
  --browser-report _build/text-spacing/browser/browser-report.json \
  --output _build/text-spacing/pdf
python tools/test_text_spacing_oracle.py
node tools/test_text_spacing_oracle.cjs

Install the pinned Python dependencies in tools/validation-requirements.txt, qpdf, Poppler and the browsers shown below. Independent checks cover PDF glyph positions and Unicode mappings, annotation bounds, browser text geometry and rendered pages. Browser witnesses measure continuous-page geometry; they do not establish equivalence with browser print pagination.

The implemented letter-spacing convention adds an advance after each grapheme, including the final grapheme of a run, as witnessed in Chromium and Firefox. There is no added space between a base character and its combining marks. normal and explicit zero retain identical shaping; nonzero letter spacing suppresses optional ligatures. These selected observations do not claim complete CSS Text module support. Text stays selectable and the same adjusted advances serve line breaking, drawing, decorations and link annotations.

The percentage indent uses the content width of the block containing the lines, not a line's temporary width beside a float. The indent is not restarted by a br, page break or later anonymous inline fragment after an in-flow child block. A descendant block has its own first-line rule. Text transformation, justification, complete font matching and the remaining decoration contexts are still pending. An excessive negative spacing that produces a negative total run advance is rejected explicitly. Preserved tabs with nonzero letter or word spacing also raise UnsupportedFeature; normal-spacing tabs retain their existing profile, without claiming exact CSS tab-stop placement.

Historical box / float / clear example

Version 0.3 renders the unchanged historical source with the native PHP engine. It combines left/right and nested floats, percentage widths, fixed heights, asymmetric borders, list-marker suppression, clearance, root backgrounds and a font shorthand. The two radios are explicit static snapshots.

Unmodified bundled HTML · Generator · Source hashes and provenance · BSD fixture notice

The generator supplies Lato as the explicit sans-serif binding, uses A4 with zero additional page margins, and keeps the HTML's own margins. It provides the source URL only as a base for annotation links; no URL is fetched. The source's Verdana family is unavailable in this catalog, so its declared generic fallback selects Lato. Font rasterization and exact line wrapping can differ from browsers.

php -d memory_limit=512M examples/generate-w3c.php _build/w3c
python tools/validate_w3c_css1.py --pdf _build/w3c/test5526c.pdf \
  --manifest _build/w3c/manifest.json --output _build/w3c/validation
npm ci --prefix tools
npm exec --prefix tools -- playwright install chromium firefox
node tools/validate_w3c_css1.cjs _build/w3c/browsers
python tools/test_w3c_css1_oracle.py
node tools/test_w3c_css1_oracle.cjs

Python dependencies are pinned in tools/validation-requirements.txt; qpdf and Poppler are also required. The browser oracle checks 50 box coordinates and 13 computed properties in each engine from identical source bytes, at 96 CSS px per inch. The PDF oracle checks source/PDF hashes, one exact A4 page, qpdf syntax, selectable source text through explicit CMaps and Poppler, clearance/text bounds, and independent color masks at 96 dpi. Edge antialiasing has a 1.25 px exclusion; color channels tolerate 4/255, with at most 0.2% mismatches per color. Font/widget areas and the font-dependent footer band are excluded from that raster mask; text content and paragraph clearance have separate checks.

This selected historical case does not qualify the whole test suite or CSS1. Floats require explicit widths and a one-page document; float pagination, float/table combinations and parent-child margin collapse in float contexts remain unsupported. Decorated normal-flow blocks overlapping earlier floats and floats introduced after text on the same line are also rejected. See coverage and usage for those boundaries.

Independent border sides

Version 0.2 adds four independent border sides and eight visible border styles. This original example presents solid, dotted, dashed, double, groove, ridge, inset and outset, followed by a box with a different style, width and color on each side. Text remains selectable; borders are PDF artifacts.

HTML source · Generator · PDF download for v0.2.0

.sides {
    border-top: 4pt solid #26788b;
    border-right: 8pt dashed #3b7557;
    border-bottom: 6pt double #ba5e24;
    border-left: 12pt dotted #78508e;
}
.rgb {
    color: rgb(-20,128,260);
    border: medium solid;
}

The last box clips RGB components to rgb(0,128,255). Its omitted border color uses currentColor. This package chooses medium = 3px = 2.25pt; thin and thick use 1px and 5px. These numeric widths are implementation choices. none uses no geometric border width; a transparent border with a visible style keeps its width. Inline border decoration and collapsed table borders remain unsupported.

The release also validates original declaration values before cascade. In Report mode an invalid later value cannot erase an earlier valid value, and an invalid shorthand cannot partially alter its sides. Ordered, bounded imports from an explicit catalog and escaped selector identifiers are covered in the usage guide. This visual example concentrates on the border/color subset; it is not evidence for every parser or import case.

To regenerate all examples and inspect their output:

php -d memory_limit=512M examples/generate.php _build/examples
python tools/validate_pdf.py --directory _build/examples

The release evidence includes independent PDF checks, every page render and Chromium/Firefox witnesses for selected computed styles and box geometry. It identifies the exact candidate and tool versions. A preview alone does not prove browser/PDF equivalence or accessibility certification.

The coverage registry records 52 partial and 10 unsupported requirements. CSS1 remains incomplete, with further text/font work remaining in the qualification sequence. No PDF/A or PDF/UA claim is made.

View the PDF result

This file was generated with the code in this documentation. All pages appear below; open the PDF to use its links and bookmarks.

PDF result from-html-css1: page 1 of 1
Page 1 of 1
Use the browser PDF viewer

This viewer depends on your browser. If the document does not appear, use “Open the PDF” or “Download”.

HTML source

Download the HTML source

Read the HTML source
<!doctype html>
<html lang="fr">
<head>
  <meta charset="utf-8">
  <title>CSS1 : bordures et cascade</title>
  <style>
    body { margin: 0; color: #173c4b; font-size: 11pt; line-height: 1.4; }
    h1 { margin: 0 0 8pt; font-size: 26pt; line-height: 1.1; }
    p { margin: 0 0 12pt; }
    .eyebrow { font-size: 9pt; color: #176a80; margin-bottom: 6pt; }
    .intro { color: #465863; }
    table { width: 100%; table-layout: fixed; margin: 0 0 14pt; }
    td { width: 50%; padding: 0 10pt 10pt 0; vertical-align: top; }
    .card { height: 39pt; padding: 9pt; border: 5pt solid #26788b; background: #edf4f5; }
    .label { font-weight: bold; font-size: 12pt; }
    .hint { font-size: 9pt; line-height: 13pt; color: #465863; }
    .dotted { border-style: dotted; }
    .dashed { border-style: dashed; }
    .double { border-style: double; }
    .groove { border-style: groove; }
    .ridge { border-style: ridge; }
    .inset { border-style: inset; }
    .outset { border-style: outset; }
    .sides { padding: 12pt; margin-bottom: 14pt; background: #f4f7f8;
      border-top: 4pt solid #26788b; border-right: 8pt dashed #3b7557;
      border-bottom: 6pt double #ba5e24; border-left: 12pt dotted #78508e; }
    .rgb { padding: 10pt; border: medium solid; color: rgb(-20,128,260); }
    .footnote { font-size: 9pt; line-height: 13pt; margin-top: 14pt; color: #465863; }
  </style>
</head>
<body>
  <div class="eyebrow">PDFTOOLKIT · MOTEUR PHP AUTONOME</div>
  <h1>CSS1, côté par côté</h1>
  <p class="intro">Huit styles de bordure, quatre côtés indépendants et des couleurs calculées avant le rendu. Le texte reste sélectionnable dans le PDF.</p>
  <table>
    <tbody>
      <tr>
        <td><div class="card"><div class="label">Solid</div><div class="hint">Une bande continue.</div></div></td>
        <td><div class="card dotted"><div class="label">Dotted</div><div class="hint">Une suite de points.</div></div></td>
      </tr>
      <tr>
        <td><div class="card dashed"><div class="label">Dashed</div><div class="hint">Des tirets réguliers.</div></div></td>
        <td><div class="card double"><div class="label">Double</div><div class="hint">Deux traits séparés.</div></div></td>
      </tr>
      <tr>
        <td><div class="card groove"><div class="label">Groove</div><div class="hint">Un sillon en relief.</div></div></td>
        <td><div class="card ridge"><div class="label">Ridge</div><div class="hint">Une arête en relief.</div></div></td>
      </tr>
      <tr>
        <td><div class="card inset"><div class="label">Inset</div><div class="hint">Une surface en retrait.</div></div></td>
        <td><div class="card outset"><div class="label">Outset</div><div class="hint">Une surface en saillie.</div></div></td>
      </tr>
    </tbody>
  </table>
  <div class="sides"><strong>Chaque côté conserve sa géométrie.</strong><br>En haut : solid. À droite : dashed. En bas : double. À gauche : dotted.</div>
  <div class="rgb"><strong>RGB borné et currentColor</strong><br>La couleur rgb(-20,128,260) devient rgb(0,128,255). La bordure reprend cette couleur avec sa largeur medium.</div>
  <p class="footnote">Exemple original de la version 0.2.0. Ces fonctions ne constituent pas une qualification complète de CSS1, de PDF/A ou de PDF/UA.</p>
</body>
</html>

Complete source code

Code from pdftoolkit/html-to-pdf · View the source at the documented commit ↗ · HTML source at the documented commit ↗

Read the commented script: generate.php
<?php

declare(strict_types=1);

use PDF\HtmlToPdf\ConversionOptions;
use PDF\HtmlToPdf\Converter;
use PDF\HtmlToPdf\Font\FontFace;
use PDF\HtmlToPdf\Font\FontSet;
use PDF\HtmlToPdf\HtmlSource;
use PDF\HtmlToPdf\Resource\ImageAsset;
use PDF\HtmlToPdf\Resource\ResourceCatalog;

require dirname(__DIR__) . '/vendor/autoload.php';

// This CLI explicitly owns file access. The library receives only immutable bytes.
$destination = $argv[1] ?? dirname(__DIR__) . '/_build/examples';
if (!is_dir($destination) && !mkdir($destination, 0777, true) && !is_dir($destination)) {
    throw new RuntimeException('Cannot create the example output directory.');
}
$read = static function (string $path): string {
    $bytes = file_get_contents($path);
    if ($bytes === false) {
        throw new RuntimeException('Cannot read ' . $path);
    }

    return $bytes;
};
$fonts = new FontSet(
    regular: new FontFace($read(__DIR__ . '/assets/fonts/Lato-Regular.ttf')),
    bold: new FontFace($read(__DIR__ . '/assets/fonts/Lato-Bold.ttf')),
    italic: new FontFace($read(__DIR__ . '/assets/fonts/Lato-Italic.ttf')),
);
$images = [];
foreach (['notebook', 'lamp', 'mug'] as $name) {
    $images[$name . '.png'] = new ImageAsset($read(__DIR__ . '/assets/images/' . $name . '.png'));
}
$options = new ConversionOptions(fonts: $fonts, resources: new ResourceCatalog(images: $images));
$converter = new Converter();
$manifest = ['php' => PHP_VERSION, 'engine' => 'native-php', 'documents' => []];
foreach (['invoice', 'catalogue', 'multipage', 'css1'] as $name) {
    $started = hrtime(true);
    $html = $read(__DIR__ . '/sources/' . $name . '.html');
    $result = $converter->convert(new HtmlSource($html), $options);
    file_put_contents($destination . '/' . $name . '.pdf', $result->pdf);
    $manifest['documents'][$name] = [
        'pages' => $result->pageCount,
        'elapsedSeconds' => (hrtime(true) - $started) / 1e9,
        'peakMemoryBytes' => memory_get_peak_usage(true),
        'sourceSha256' => hash('sha256', $html),
        'pdfSha256' => hash('sha256', $result->pdf),
        'bytes' => strlen($result->pdf),
        'diagnostics' => $result->diagnostics,
    ];
    fwrite(STDOUT, $name . ': ' . $result->pageCount . ' page(s), ' . strlen($result->pdf) . " bytes\n");
}
file_put_contents($destination . '/manifest.json', json_encode($manifest, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_THROW_ON_ERROR) . "\n");

Historical W3C CSS1 sample

The historical W3C test5526c.htm source is converted unchanged in PHP. Radio controls are explicit static snapshots. The verified geometry does not establish complete CSS1 conformance.

PDF result from-html-w3c-css1: page 1 of 1
Page 1 of 1
Use the browser PDF viewer

This viewer depends on your browser. If the document does not appear, use “Open the PDF” or “Download”.

HTML source

Download the HTML source

Read the HTML source
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html>
	<head>
		<title>
			 display/box/float/clear test 
		</title>
 	<style type="text/css">
/* last modified: 1 Dec 98 */ 	

html {
font: 10px/1 Verdana, sans-serif;
background-color: blue;
color: white;
}

body {
margin: 1.5em;
border: .5em solid black;
padding: 0;
width: 48em;
background-color: white;
}

dl {
margin: 0;
border: 0;
padding: .5em;
}

dt { 
background-color: rgb(204,0,0);
margin: 0; 
padding: 1em;
width: 10.638%; /* refers to parent element's width of 47em. = 5em or 50px */
height: 28em;
border: .5em solid black;
float: left;
}

dd {
float: right;
margin: 0 0 0 1em;
border: 1em solid black;
padding: 1em;
width: 34em;
height: 27em;
}

ul {
margin: 0;
border: 0;
padding: 0;
}

li {
display: block; /* i.e., suppress marker */
color: black;
height: 9em;
width: 5em;
margin: 0;
border: .5em solid black;
padding: 1em;
float: left;
background-color: #FC0;
}

#bar {
background-color: black;
color: white;
width: 41.17%; /* = 14em */
border: 0;
margin: 0 1em;
}

#baz {
margin: 1em 0;
border: 0;
padding: 1em;
width: 10em;
height: 10em;
background-color: black;
color: white;
}

form { 
margin: 0;
display: inline;
}

p { 
margin: 0;
}

form p {
line-height: 1.9;
}

blockquote {
margin: 1em 1em 1em 2em;
border-width: 1em 1.5em 2em .5em;
border-style: solid;
border-color: black;
padding: 1em 0;
width: 5em;
height: 9em;
float: left;
background-color: #FC0;
color: black;
}

address {
font-style: normal;
}

h1 {
background-color: black;
color: white;
float: left;
margin: 1em 0;
border: 0;
padding: 1em;
width: 10em;
height: 10em;
font-weight: normal;
font-size: 1em;
}
  </style>
	</head>
	<body>
		<dl>
			<dt>
			 toggle 
			</dt>
			<dd>
			<ul>
				<li>
				 the way 
				</li>
				<li id="bar">
				<p>
				 the world ends 
				</p>
				<form action="./" method="get">
					<p>
					 bang 
					<input type="radio" name="foo" value="off">
					</p>
					<p>
					 whimper 
					<input type="radio" name="foo2" value="on">
					</p>
				</form>
				</li>
				<li>
				 i grow old 
				</li>
				<li id="baz">
				 pluot? 
				</li>
			</ul>
			<blockquote>
				<address>
					 bar maids, 
				</address>
			</blockquote>
			<h1>
				 sing to me, erbarme dich 
			</h1>
			</dd>
		</dl>
		<p style="color: black; font-size: 1em; line-height: 1.3em; clear: both">
		 This is a nonsensical document, but syntactically valid HTML 4.0. All 100%-conformant CSS1 agents should be able to render the document elements above this paragraph indistinguishably (to the pixel) from this 
			<a href="sec5526c.gif">reference rendering,</a>
		 (except font rasterization and form widgets). All discrepancies should be traceable to CSS1 implementation shortcomings. Once you have finished evaluating this test, you can return to the <A HREF="sec5526c.htm">parent page</A>. 
		</p>
	</body>
</html>

JSON generation receipt · Independent JSON validation

Complete source code

Code from pdftoolkit/html-to-pdf · View the source at the documented commit ↗ · HTML source at the documented commit ↗

Read the commented script: generate-w3c.php
<?php

declare(strict_types=1);

use PDF\HtmlToPdf\ConversionOptions;
use PDF\HtmlToPdf\Converter;
use PDF\HtmlToPdf\Font\FontCatalog;
use PDF\HtmlToPdf\Font\FontFace;
use PDF\HtmlToPdf\Font\FontSet;
use PDF\HtmlToPdf\FormControls;
use PDF\HtmlToPdf\HtmlSource;
use PDF\HtmlToPdf\Layout\PageSettings;
use PDF\HtmlToPdf\Style\Edges;

require dirname(__DIR__) . '/vendor/autoload.php';

// File access belongs to this example CLI; the converter receives explicit bytes only.
$destination = $argv[1] ?? dirname(__DIR__) . '/_build/w3c';
if (!is_dir($destination) && !mkdir($destination, 0777, true) && !is_dir($destination)) {
    throw new RuntimeException('Cannot create the witness output directory.');
}
$read = static function (string $path): string {
    return file_get_contents($path) ?: throw new RuntimeException('Cannot read ' . $path);
};
$html = $read(dirname(__DIR__) . '/resources/css1/w3c/test5526c.htm');
$bytes = $read(__DIR__ . '/assets/fonts/Lato-Regular.ttf');
$regular = new FontFace($bytes);
$sans = new FontSet($regular);
$fonts = new FontSet($regular, catalog: new FontCatalog(genericFamilies: ['sans-serif' => $sans]));
$options = new ConversionOptions($fonts, new PageSettings(margin: new Edges()), formControls: FormControls::StaticSnapshot);
$result = (new Converter())->convert(new HtmlSource($html, baseUri: 'https://www.w3.org/Style/CSS/Test/CSS1/current/test5526c.htm'), $options);
file_put_contents($destination . '/test5526c.pdf', $result->pdf);
file_put_contents($destination . '/manifest.json', json_encode([
    'engine' => 'native-php', 'php' => PHP_VERSION, 'sourceSha256' => hash('sha256', $html),
    'pdfSha256' => hash('sha256', $result->pdf), 'pages' => $result->pageCount,
    'diagnostics' => $result->diagnostics, 'fonts' => [['family' => 'Lato (explicit sans-serif binding)', 'sha256' => hash('sha256', $bytes)]],
    'formControls' => 'static-snapshot',
], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n");
fwrite(STDOUT, 'test5526c: ' . $result->pageCount . ' page(s), ' . strlen($result->pdf) . " bytes\n");

CSS1 text spacing and indentation

Three native PDF pages show signed spacing, combining marks and first-line indentation, including page continuation. Chromium/Firefox measurements and PDF checks are available to download; they do not qualify complete CSS1.

PDF result from-html-text-spacing: page 1 of 3
Page 1 of 3
PDF result from-html-text-spacing: page 2 of 3
Page 2 of 3
PDF result from-html-text-spacing: page 3 of 3
Page 3 of 3
Use the browser PDF viewer

This viewer depends on your browser. If the document does not appear, use “Open the PDF” or “Download”.

HTML source

Download the HTML source

Read the HTML source
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>CSS1 text spacing and first-line indentation</title>
  <style>
    body { margin: 0; font-family: sans-serif; font-size: 16px; line-height: 24px; color: #173c4b; }
    h1 { font-weight: normal; font-size: 24px; line-height: 30px; margin: 0 0 12px; }
    p { margin: 0 0 8px; }
    .intro { font-size: 12px; line-height: 18px; margin-bottom: 18px; }
    .case { width: 520px; }
    .wide-words { word-spacing: 6px; }
    .tight-words { word-spacing: -2px; }
    .wide-letters { letter-spacing: 2px; }
    .tight-letters { letter-spacing: -1px; }
    .inherited { font-size: 20px; word-spacing: .3em; letter-spacing: .1em; }
    .inherited span { font-size: 16px; }
    .indent { width: 160px; margin-left: 24px; margin-bottom: 12px; }
    .positive { text-indent: 24px; }
    .negative { text-indent: -12px; }
    .percent { text-indent: 10%; }
    .page { page-break-before: always; }
    .continuation { width: 180px; text-indent: 24px; line-height: 160px; }
    a { color: #173c4b; text-decoration: none; }
  </style>
</head>
<body>
  <h1>CSS1: space, rhythm and first lines</h1>
  <p class="intro">Explicit font bytes, selectable Unicode text and an independent browser/PDF geometry witness. Values below use CSS pixels; 1px = 0.75 PDF point.</p>
  <p id="word-normal" class="case">W0 A B C D</p>
  <p id="word-positive" class="case wide-words">W1 A B C D</p>
  <p id="word-negative" class="case tight-words">W2 A B C D</p>
  <p id="nbsp-normal" class="case">N0 A&nbsp;B&nbsp;C&nbsp;D</p>
  <p id="nbsp-positive" class="case wide-words">N1 A&nbsp;B&nbsp;C&nbsp;D</p>
  <p id="nbsp-negative" class="case tight-words">N2 A&nbsp;B&nbsp;C&nbsp;D</p>
  <p id="letter-normal" class="case">L0 ABCD</p>
  <p id="letter-positive" class="case wide-letters"><a href="https://example.org/css1-spacing">L1 ABCD</a></p>
  <p id="letter-negative" class="case tight-letters">L2 ABCD</p>
  <p id="combined" class="case wide-words wide-letters">C0 A B C D</p>
  <p id="inherited" class="case inherited"><span>E0 A B C D</span></p>
  <p id="combining-normal" class="case">M0 a&#x301;b</p>
  <p id="combining-positive" class="case wide-letters">M1 a&#x301;b</p>
  <p id="ligature-normal" class="case">F0 office</p>
  <p id="ligature-positive" class="case wide-letters">F1 office</p>
  <p id="indent-positive" class="indent positive">I0 MMMM MMMM MMMM MMMM MMMM MMMM</p>
  <p id="indent-negative" class="indent negative">I1 MMMM MMMM MMMM MMMM MMMM MMMM</p>
  <p id="indent-percent" class="indent percent">I2 MMMM MMMM MMMM MMMM MMMM MMMM</p>
  <p class="intro page">Pagination witness: the first-line indent is not repeated after a page break.</p>
  <p id="page-continuation" class="continuation">P0 AAAA BBBB CCCC DDDD EEEE FFFF GGGG HHHH IIII JJJJ KKKK LLLL MMMM NNNN OOOO PPPP QQQQ RRRR SSSS TTTT UUUU VVVV WWWW XXXX YYYY ZZZZ</p>
</body>
</html>

JSON generation receipt · Independent JSON validation

Chromium/Firefox JSON measurements

Complete source code

Code from pdftoolkit/html-to-pdf · View the source at the documented commit ↗ · HTML source at the documented commit ↗

Read the commented script: generate-text-spacing.php
<?php

declare(strict_types=1);

use PDF\HtmlToPdf\ConversionOptions;
use PDF\HtmlToPdf\Converter;
use PDF\HtmlToPdf\Font\FontCatalog;
use PDF\HtmlToPdf\Font\FontFace;
use PDF\HtmlToPdf\Font\FontSet;
use PDF\HtmlToPdf\HtmlSource;

require dirname(__DIR__) . '/vendor/autoload.php';

// File access belongs to this example CLI; conversion receives explicit bytes.
$destination = $argv[1] ?? dirname(__DIR__) . '/_build/text-spacing';
if (!is_dir($destination) && !mkdir($destination, 0777, true) && !is_dir($destination)) {
    throw new RuntimeException('Cannot create the text-spacing output directory.');
}
$read = static function (string $path): string {
    $bytes = file_get_contents($path);
    return $bytes === false ? throw new RuntimeException('Cannot read ' . $path) : $bytes;
};
$html = $read(__DIR__ . '/sources/text-spacing.html');
$font = $read(dirname(__DIR__) . '/tests/Fixtures/fonts/NotoSans-Regular.ttf');
$regular = new FontFace($font);
$fonts = new FontSet($regular, catalog: new FontCatalog(genericFamilies: ['sans-serif' => new FontSet($regular)]));
$result = (new Converter())->convert(new HtmlSource($html), new ConversionOptions($fonts));
file_put_contents($destination . '/text-spacing.pdf', $result->pdf);
file_put_contents($destination . '/manifest.json', json_encode([
    'engine' => 'native-php', 'php' => PHP_VERSION,
    'sourceSha256' => hash('sha256', $html), 'pdfSha256' => hash('sha256', $result->pdf),
    'pages' => $result->pageCount, 'diagnostics' => $result->diagnostics,
    'fonts' => [['family' => 'Noto Sans (explicit fallback)', 'sha256' => hash('sha256', $font)]],
], JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR) . "\n");
fwrite(STDOUT, 'text-spacing: ' . $result->pageCount . ' page(s), ' . strlen($result->pdf) . " bytes\n");

Guide source at the documented commit ↗