Sierra guide / Around Sierra
PDFs and images with print-kit
@frontierjs/print-kit turns an HTML document into a PDF and an element into a PNG, in one headless Chromium. It needs Chrome or Chromium on the machine, so this page does not run its example.
import { createPrinter, printDocument } from '@frontierjs/print-kit'
const printer = createPrinter()
const html = printDocument({ title: 'Invoice 12', body: '<h1>Invoice 12</h1>' })
const pdf = await printer.pdf(html)
await printer.close()
What else it can do
printDocumentalso takescsssheets, alangand apagespec for paper size and margin boxesprinter.png(html, '#chart')captures one element as an imageapp.use(printer())in a Junction app claimsapp.printer, so a service or a job can print- With no Chrome on the machine the app refuses to boot, by name
- The page runs offline with scripts off, so a URL in it cannot make the server fetch anything
@frontierjs/print-kit/print.cssis the stylesheet every printed document carries, with page groups and break rules- The browser is opened on the first job and shared after that
In depth: print-kit README