flext2pdf
v1.2.3
Published
A Powerful Templating Engine
Maintainers
Readme
flext2pdf
flext2pdf converts Flext templates into PDFs using Playwright. It launches a headless Chromium instance to render your HTML and returns the resulting file through a tiny API. The library ships with ESM and CJS bundles.
Documentation: Available at TrustMe Wiki.
flext2pdf is maintained by TrustMe.
Here's a simple example:
import flext2pdf from 'flext2pdf';
const template = `
{{!-- @v "1.0.beta3" --}}
{{!-- @use "put" --}}
<div>{{ put data.helloWorld "No hello world..." }}</div>
`;
const data = { helloWorld: 'Hello World!' };
const converter = await flext2pdf();
const pdf = await converter.pdf(template, { data });
await converter.clear();Installation
- Install dependencies:
npm i flext2pdf @trustme24/flext
npx flext2pdf install chromiumMake sure your system provides glibc \u2265 2.28; Playwright's Chromium relies on it.
You're all set!
Tips & Tricks
- Pass an existing
browserorpagetoflext2pdf()to reuse Playwright sessions. - Call
converter.clear()to close the browser and free resources when finished. - Pre-install Chromium in CI or Docker with
npx flext2pdf install chromiumto avoid downloads at runtime. - Forward
format,background, or other options to customizepage.pdfoutput.
flext2pdf by Kenny Romanov
TrustMe
