Typesetter's Son
Typesetter's Son is a small utility for generating images and PDFs based on lightly modified webpages. It loads a URL in Headless Chrome, substitutes innerHTML for elements you specify, and takes a screenshot.
It works great on SVGs too -- just sprinkle in id
attributes where you want to modify text!
Installation
Library: npm install typesetters-son
Executable: npm install -g typesetters-son
Example:
typesetters-son http://dogpatchjs.com/banner -o dogpatch.png -w 1024 -c 'body' -s '{"#day": "Monday, July 17, 2017", "#where": "Spark Social", "#time": "6:30pm"}'
typesetters-son http://dogpatchjs.com/banner -o dogpatch.pdf -p Letter -s '{"#day": "Monday, July 17, 2017", "#where": "Spark Social", "#time": "6:30pm"}'
Library Usage
const generateImage = const generatePDF =
Executable Usage
Usage: typesetters-son URL -o [path]
Options:
--output, -o output image/pdf path [required]
--width, -w viewport width [default: 800]
--height, -h viewport height [default: 600]
--crop, -c element query to crop around
--density, -d pixel density [default: 1]
--paper, -p paper size (e.g. Letter, A4, etc.) [default: "Letter"]
--remove-bg remove bg colors (for printing) [boolean] [default: false]
--subs, -s text substitutions (JSON)