Skip to content

Engine extension

NextPDF Artisan

Chrome CDP renderer — pixel-perfect HTML/CSS3 to text-selectable PDF.

Free · Apache-2.0NextPDF ^3.0 · chrome-php/chrome ^1.15 · Chrome/Chromium · PHP 8.4+

NextPDF Artisan bridges Chrome's rendering engine with NextPDF via the Chrome DevTools Protocol (CDP). It renders HTML through Chrome's printToPDF, parses the output, and embeds each page as a Form XObject — producing text-selectable, searchable PDF output, not rasterized images.

How it fits

Built into your workflow

Modern CSS3, at the final rendered frame

Artisan renders your HTML through Chrome, covering modern CSS3 features such as Flexbox and Grid layouts, custom web fonts, inline SVG, and CSS animations. The page is captured at its final rendered frame, so the layout you build in the browser is the layout that lands in the PDF.

Selectable text, not flattened pixels

Each rendered page is embedded into the PDF as a Form XObject rather than a rasterized image, so the text layer survives as real, selectable glyphs. Viewport sizing follows the standard 72pt-per-inch to 96px-per-inch conversion for accurate print geometry. The result reads, searches, and copies like a true document.

A managed, sandboxed BrowserPool

Chrome instances are managed in a sandboxed BrowserPool that automatically restarts each browser after 100 renders to keep memory usage in check. A built-in PDF parser, tokenizer, xref reader, and stream decoder round out the pipeline. You get steady, long-running rendering without the memory leaks of a single long-lived browser.

Get started

Install

terminal
composer require nextpdf/artisan

In code

How it works

Render HTML via Chrome

php
use NextPDF\Core\Document;
use NextPDF\Artisan\ChromeRendererConfig;

$config = new ChromeRendererConfig(
    chromeBinaryPath: '/usr/bin/google-chrome',
);

$doc = Document::createStandalone();
$doc->setChromeRendererConfig($config);
$doc->addPage();

$doc->writeHtmlChrome('<h2>Revenue</h2><p style="font-size: 2em;">$124,500</p>');

$doc->save('/path/to/report.pdf');

Custom viewport size

php
$doc->writeHtmlChrome($html, width: 595.28, height: 841.89); // A4

Capabilities

What you get

  • Full CSS3 — Flexbox, Grid, custom web fonts, SVG, animations (rendered at final frame)
  • Text-selectable — pages embedded as Form XObjects preserve text layers for search and copy
  • Viewport conversion — seamless 72 pt/inch (PDF) to 96 px/inch (CSS) coordinate mapping
  • BrowserPool — automatic Chrome restart after 100 renders to prevent memory leaks
  • Security policy — sandboxed rendering with --disable-gpu, --disable-extensions, restricted network
  • PDF parser — built-in tokenizer, cross-reference parser, and stream decoder

When to use it

Reach for Artisan when you need pixel-perfect HTML/CSS3 layouts (Flexbox, Grid, web fonts, SVG) rendered to PDF while keeping text selectable and searchable, rather than rasterized.