Skip to content

Engine extension

NextPDF Artisan

Chrome CDP renderer—HTML with Flexbox, Grid, web fonts, and SVG to text-selectable PDF.

Free · Apache-2.0NextPDF ^3.0 || ^5.2 · chrome-php/chrome ^1.15 · Chrome/Chromium · PHP >=8.4 <9.0

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 with text-selectable, searchable content.

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, searchable text

Each rendered page is embedded into the PDF as a Form XObject, preserving the text layer as real, selectable glyphs. Viewport sizing follows the standard 72pt-per-inch to 96px-per-inch conversion for accurate print geometry. The result supports reading, searching, and copying as document text.

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. Browser recycling isolates memory for steady, long-running rendering.

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—maps 72 pt/inch (PDF) to 96 px/inch (CSS) coordinates
  • 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 HTML/CSS3 layouts with Flexbox, Grid, web fonts, and SVG rendered to PDF with selectable, searchable text.