Find your next open-source project

Search by name, purpose, or keyword — or paste a GitHub repository URL

nforst/fagus

Developer Tools

PHP/Laravel package that renders HTML+CSS to PDF with a native Rust engine, no browser required

143
2
Rust
Apache-2.0
7 days old

What it does

Fagus is a Composer package that converts HTML and CSS into PDF without Chrome, Puppeteer, Node, Docker, or system libraries. A native Rust engine is downloaded per platform by Composer and kept alive as a worker process between documents, so PHP can call it over pipes. The project targets PHP and Laravel applications that generate invoices, reports, and similar print documents.

The engine aims to print like Chrome: flex, grid, Tailwind v4, @page margin boxes, running headers, page counters, and repeated table headers. It also covers tagged PDF/UA-1 accessibility, PDF/A variants, and ZUGFeRD/Factur-X invoice attachments. The README labels the project as early development, with CSS coverage still growing and minor releases allowed to change the API before 1.0.

Getting started

Requires PHP 8.3 or newer. Install the package with Composer; it asks whether to trust the plugin that installs the fagus binary on each install/update.

composer require nforst/fagus

Render a string to a PDF:

use Fagus\Fagus;

Fagus::html($html)->save('invoice.pdf');

For options such as a base directory, resources, PDF/A conformance, Factur-X, and diagnostics:

use Fagus\Conformance;
use Fagus\Fagus;

$pdf = Fagus::html($html)
    ->baseDirectory(__DIR__.'/resources/pdf')
    ->resource('logo.png', $logo)
    ->pdfA(Conformance::PdfA3b)
    ->facturX($invoiceXml)
    ->render();

$pdf->save('invoice.pdf');
$pdf->diagnostics();

In Laravel, the same package registers a Fagus facade, Blade view rendering, responses, and disks. Publish the config with php artisan vendor:publish --tag=fagus-config, then return Fagus::view('invoices.show', ['invoice' => $invoice])->name('invoice.pdf') for inline output. A getting-started guide walks through the first PDF, and deployment docs cover Docker, Alpine, servers without GitHub access, and custom binaries.

The engine also runs standalone as a CLI and Rust library, e.g. fagus render invoice.html -o invoice.pdf --font-dir fonts --factur-x invoice.xml.

Constraints

  • JavaScript is deliberately not executed; charts must be rendered server-side as SVG or images.
  • Font behavior depends on configuration: system fonts are off by default to keep output identical across machines, but can be enabled per platform.
  • CSS coverage is still growing before 1.0; a minor release may change the API. The changelog and stability page describe the policy.
  • Self-contained operation is advertised for Linux x64/arm64, macOS Intel/Apple silicon, and Windows x64.
  • Licensed under Apache-2.0 or MIT at your option.

HotRepo's take

The project appeared on the Rust new-repository list on 2026-11-20 with 4 stars gained over roughly 1.5 hours and 106 stars total. That is a small, early record without a GitHub daily-rank placement, so it supports no trend claim. The technically notable angle is the browser-free approach: the README's own benchmarks on an Apple M2 Pro put Fagus at about 9 ms for the first one-page invoice and 2.3 ms for subsequent ones, versus 103/75 ms for a kept-running Chrome and 63/25 ms for mPDF. Those numbers come from the project's benchmark setup rather than independent testing, but they explain why a PHP invoice generator with modern CSS support may be worth watching as it matures toward 1.0.

Written by AI from the project's README, updated . The project's own docs are the source of truth.

You might also like

  1. gotenberg/gotenbergA Docker-based HTTP API that converts HTML, URLs and office documents to PDF and post-processes them.Go13,594
  2. rauchg/xeetRender X posts to pixel-accurate PNGs without a browser, in Rust and WebAssembly.JavaScript105
  3. symfony/symfonyA PHP framework and reusable component set for building web and console applications.PHP31,243
  4. grpc/grpcA cross-language RPC framework that lets services call each other as typed functions over HTTP/2.C++45,402
  5. axios/axiosPromise-based HTTP client for browsers and Node.js, used for sending requests and handling responses with interceptors, cancellation and progress support.JavaScript109,393