danburzo / percollate
- суббота, 13 октября 2018 г. в 00:20:27
JavaScript
🌐 → 📖 A command-line tool to grab web pages as beautifully formatted PDFs
Percollate is a command-line tool to turn web pages as beautifully formatted PDFs.
💡 percollateneeds Node.js version 8 or later, as it uses new(ish) JavaScript syntax.
You can install percollate globally:
# using npm
npm install -g percollate
# using yarn
yarn global add percollateTo keep the package up-to-date, you can run:
# using npm, upgrading is the same command as installing
npm install -g percollate
# yarn has a separate command
yarn global upgrade --latest percollate
💡 Runpercollate --helpfor a list of available commands. For a particular command,percollate <command> --helplists all available options.
| Command | What it does |
|---|---|
percollate pdf |
Bundles one or more web pages into a PDF |
percollate epub |
Not implemented yet |
percollate html |
Not implemented yet |
The pdf, epub, and html commands have these options:
| Option | What it does |
|---|---|
-o, --output |
(Required) The path of the resulting bundle |
--template |
Path to a custom HTML template |
--style |
Path to a custom CSS |
To transform a single web page to PDF:
percollate pdf --output some.pdf https://example.comTo bundle several web pages into a single PDF, specify them as separate arguments to the command:
percollate pdf --output some.pdf https://example.com/page1 https://example.com/page2You can use common Unix commands and keep the list of URLs in a newline-delimited text file:
cat urls.txt | xargs percollate pdf --output some.pdf
⚠️ TODO add example here
⚠️ TODO add example here
⚠️ TODO add example here
gotjsdommozilla/readability to strip unnecessary elementspuppeteer to generate a PDF from the pageOn some Linux machines you'll need to install a few more Chrome dependencies before percollate works correctly. (Thanks to @ptica for sorting it out)
The percollate pdf command supports the --no-sandbox Puppeteer flag, but make sure you're aware of the implications before disabling the sandbox.
Here are some other projects to check out if you're interested in building books using the browser: