Skip to content

Commit

Permalink
Fixes danburzo#26; adds support for --no-sandbox. Add note about node…
Browse files Browse the repository at this point in the history
….js version requirements
  • Loading branch information
danburzo committed Oct 12, 2018
1 parent 2e69ef3 commit 878324f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Percollate is a command-line tool to turn web pages as beautifully formatted PDF

## Installation

> 💡 `percollate` needs Node.js version 8 or later, as it uses new(ish) JavaScript syntax.
You can install `percollate` globally:

```bash
Expand Down Expand Up @@ -92,6 +94,8 @@ cat urls.txt | xargs percollate pdf --output some.pdf

On some Linux machines you'll need to [install a few more Chrome dependencies](https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#chrome-headless-doesnt-launch) before `percollate` works correctly. (_Thanks to @ptica for [sorting it out](https://github.com/danburzo/percollate/issues/19#issuecomment-428496041)_)

The `percollate pdf` command supports the `--no-sandbox` Puppeteer flag, but make sure you're [aware of the implications](https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#chrome-headless-fails-due-to-sandbox-issues) before disabling the sandbox.

## See also

Here are some other projects to check out if you're interested in building books using the browser:
Expand Down
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ async function bundle(items, options) {

console.log('Saving as PDF');
const browser = await pup.launch({
headless: true
headless: true,
/*
Allow running with no sandbox
See: https://github.com/danburzo/percollate/issues/26
*/
args: options.sandbox
? undefined
: ['--no-sandbox', '--disable-setuid-sandbox']
});
const page = await browser.newPage();
await page.goto(`file://${temp_file}`, { waitUntil: 'load' });
Expand Down Expand Up @@ -160,6 +167,7 @@ function with_common_options(cmd) {
program.version(pkg.version);

with_common_options(program.command('pdf [urls...]'))
.option('--no-sandbox', 'Passed to Puppeteer')
.description('Bundle web pages as a PDF file')
.action(pdf);

Expand Down

0 comments on commit 878324f

Please sign in to comment.