Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chromakode/typesetters-son
Utility for generating images of lightly modified webpages
https://github.com/chromakode/typesetters-son
headless-chrome screenshot utility
Last synced: 23 days ago
JSON representation
Utility for generating images of lightly modified webpages
- Host: GitHub
- URL: https://github.com/chromakode/typesetters-son
- Owner: chromakode
- License: mit
- Created: 2017-09-02T00:01:21.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-26T00:00:22.000Z (almost 6 years ago)
- Last Synced: 2024-09-19T14:12:25.868Z (about 2 months ago)
- Topics: headless-chrome, screenshot, utility
- Language: JavaScript
- Size: 188 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Typesetter's Son
[![npm](https://img.shields.io/npm/v/typesetters-son.svg?style=flat-square)](https://www.npmjs.com/package/typesetters-son)
[![license](https://img.shields.io/npm/l/typesetters-son.svg?style=flat-square)](https://github.com/chromakode/typesetters-son/blob/master/LICENSE)[![Named for "Typesetter's Son" on Channel101](typesetters-son.jpg)](http://www.channel101.com/episode/1667)
Typesetter's Son is a small utility for generating images and PDFs based on lightly modified webpages. It loads a URL in [Headless Chrome](https://github.com/GoogleChrome/puppeteer), 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"}'`
![Example output](example.png)
## Library Usage
```js
const {generateImage} = require('typesetters-son')
generateImage({
url: 'http://dogpatchjs.com/banner',
output: 'dogpatch.png',
width: 1024,
height: 800,
density: 1, // defaults to 1 if unspecified
crop: 'body',
subs: {
'#day': new Date().toDateString(),
'#where': 'Spark Social',
'#time': '6:30pm',
},
})const {generatePDF} = require('typesetters-son')
generatePDF({
url: 'http://dogpatchjs.com/banner',
output: 'dogpatch.pdf',
paper: 'Letter',
removeBackground: false,
subs: {
'#day': new Date().toDateString(),
'#where': 'Spark Social',
'#time': '6:30pm',
},
})
```## 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)
```