GD also draws: imageline(), imagerectangle(), imagefilledellipse() and imagefilledpolygon() take coordinates and a color, and imagesetthickness() sets the pen; the crop square in 4.19.7's figure is one imagerectangle() call. For documents, render HTML to PDF with Dompdf 11,192 (github.com/dompdf/dompdf (https://github.com/dompdf/dompdf 11,192 ), LGPL-2.1, 3.1.6 of 20 July 2026), pure PHP with CSS 2.1 and some CSS3 but no flexbox or grid, and write spreadsheets with PhpSpreadsheet 13,990 (github.com/PHPOffice/PhpSpreadsheet (https://github.com/PHPOffice/PhpSpreadsheet 13,990 ), MIT, 5.10.0); plain CSV needs only fputcsv() (CSV and INI Files).
<?php
declare(strict_types=1);
require 'vendor/autoload.php';
$items = ['Clean PHP' => 29.50, 'SQL Pocket Guide' => 13.00];
$rows = implode('', array_map(fn($t, $p) => '<tr><td>' . htmlspecialchars($t)
. sprintf('</td><td class="r">%.2f</td></tr>', $p), array_keys($items), $items));
$pdf = new Dompdf\Dompdf(['isRemoteEnabled' => false]); // never fetch URLs from the HTML
$pdf->loadHtml(sprintf(<<<'HTML'
<style>body { font-family: 'DejaVu Sans'; } table { width: 100%%; } h1 { color: #1565c0; }
th { background: #37474f; color: #fff; text-align: left; } td, th { padding: 6px; }
.r { text-align: right; }</style>
<h1>Invoice #1001</h1><p>Billed to: Zoë Reader, 23 September 2026</p>
<table><tr><th>Title</th><th class="r">USD</th></tr>%s
<tr><td><b>Total</b></td><td class="r"><b>%.2f</b></td></tr></table>
HTML, $rows, array_sum($items)));
$pdf->setPaper('A5');
$pdf->render();
printf("pdf: %d bytes\n", file_put_contents('invoice-1001.pdf', $pdf->output()));
$sheet = ($book = new PhpOffice\PhpSpreadsheet\Spreadsheet())->getActiveSheet();
$sheet->fromArray([...array_map(null, array_keys($items), $items), ['Total', '=SUM(B1:B2)']]);
(new PhpOffice\PhpSpreadsheet\Writer\Xlsx($book))->save('invoice-1001.xlsx');
printf("xlsx: %d bytes, B3 %s = %s\n", filesize('invoice-1001.xlsx'),
$sheet->getCell('B3')->getValue(), $sheet->getCell('B3')->getCalculatedValue());pdf: 17237 bytes xlsx: 6176 bytes, B3 =SUM(B1:B2) = 42.5

The bundled DejaVu fonts cover the "ë", and B3 stays a live formula that Excel recalculates. pdftoppm (poppler-utils) made the PNG; pdftotext or smalot/pdfparser reads text back out.