Use the `automatic` command
masterautomatic command (which is the default if no command is specified) iterates over available plugins and automatically picks the compatible one for the provided URL to export the presentation to a PDF.repository·master·Indexed 25 days ago
https://github.com/astefanutti/decktapeA high-quality PDF exporter for HTML presentation frameworks such as Reveal.js, Remark, and Bespoke.js. Using Puppeteer and headless Chrome, it provides a CLI to capture slide decks as PDFs or images, featuring automatic framework detection, custom viewport sizing, slide range selection, and support for Docker and NPM installation.
automatic command (which is the default if no command is specified) iterates over available plugins and automatically picks the compatible one for the provided URL to export the presentation to a PDF.You can install DeckTape globally to run it directly from your terminal, or install it locally within a project.
Global installation:
$ npm install -g decktape
$ decktapeLocal installation:
$ npm install decktape
$ npm exec decktape$ npm install -g decktape
$ decktapeDeckTape can be executed using the ghcr.io/astefanutti/decktape container image. This is useful for environments where you don't want to install Node.js or Puppeteer locally.
Convert an online presentation to a local PDF:
Mount the current working directory to /slides inside the container so the output is written to your host filesystem.
$ docker run --rm -t -v `pwd`:/slides ghcr.io/astefanutti/decktape https://revealjs.com/demo/ slides.pdfConvert a local HTML file: Mount both your current directory and the directory containing your slides.
$ docker run --rm -t -v `pwd`:/slides -v ~:/home/user ghcr.io/astefanutti/decktape /home/user/slides.html slides.pdfConvert a presentation on localhost:
Use --net=host to allow the container to access your host's network. Note that on macOS and Windows, you may need to use host.docker.internal instead of localhost.
$ docker run --rm -t --net=host -v `pwd`:/slides ghcr.io/astefanutti/decktape http://localhost:8000 slides.pdfDeckTape is a command-line tool that uses a browser (via Puppeteer) to capture slide decks and export them as PDF files. It automatically detects compatible plugins for the provided URL.
Basic Usage:
decktape <url> <filename>
Example:
decktape https://impress.js.org/ my_slides.pdfIf you encounter sandbox errors (common on Arch Linux), pass the --no-sandbox flag to Chrome:
$ decktape ... --chrome-arg=--no-sandboxIf the page is HTTPS but requests insecure resources, allow insecure content:
$ decktape ... --chrome-arg=--allow-running-insecure-contentIf you see Failed to read the 'rules' property from 'CSSStyleSheet', you may need to disable web security to allow access to local/external stylesheets:
$ decktape ... --chrome-arg=--disable-web-securityIf the layout looks wrong, try setting a specific viewport size using the -s option:
$ decktape -s 1024x768 <url> <filename>Do not append ?print-pdf to the URL or load print stylesheets when using DeckTape with Reveal.js, as DeckTape captures slides individually.
The generic command works by emulating end-user interaction. It is useful for HTML presentation frameworks that do not expose an API or accessible state.
It works by pressing a specified --key (defaulting to ['ArrowRight']) and continues as long as:
--max-slides.Example: Using custom keys
$ decktape generic --key=ArrowDown --key=ArrowRight <url> <filename>$ decktape generic --key=ArrowDown --key=ArrowRightThe use object in the Playwright configuration defines shared settings for all test projects. In this repository, it configures:
actionTimeout: Set to 0 (no limit), meaning actions like click() will not time out by default.trace: Set to 'on-first-retry', which collects a Playwright trace only when a test fails and is being retried.baseURL: Set to http://localhost:3010 (via the port constant), allowing tests to use relative paths in commands like await page.goto('/'). use: {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
baseURL: `http://localhost:${port}`
},The playwright.config.ts file defines the execution environment for DeckTape's Playwright-based tests. Key configuration areas include:
testDir to ./test, a global timeout of 30 seconds, and enables fullyParallel execution.expect.timeout is set to 5000ms, which is the maximum time expect() calls will wait for conditions to be met.process.env.CI is truthy), the configuration automatically enables forbidOnly, sets retries to 2, and limits workers to 1 to prevent parallelization issues.html reporter to generate test results.node test/run-server.js ${port} before running tests, reusing the existing server if it is already running.const config: PlaywrightTestConfig = {
testDir: './test',
timeout: 30 * 1000,
expect: {
timeout: 5000
},
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
use: {
actionTimeout: 0,
trace: 'on-first-retry',
baseURL: `http://localhost:${port}`
},
projects: [
{
name: 'firefox',
use: devices['Desktop Firefox'],
}
],
webServer: {
command: `node test/run-server.js ${port}`,
port,
reuseExistingServer: true,
},
};General options available for most commands:
| Option | Description |
|---|---|
-s, --size <size> | Size of the viewport (e.g. 1280x720) |
-p, --pause <ms> | Duration in ms before each slide is exported [1000] |
--load-pause <ms> | Duration in ms between page load and export start [0] |
--url-load-timeout <ms> | Timeout for initial URL load [60000] |
--page-load-timeout <ms> | Timeout for slide deck page load [20000] |
--buffer-timeout <ms> | Timeout waiting for slide buffering [30000] |
--screenshots | Capture each slide as an image [false] |
--screenshots-directory <dir> | Screenshots output directory [screenshots] |
--screenshots-size <size> | Screenshots resolution (can be repeated) |
--screenshots-format <format> | Image format: jpg, png [png] |
--slides <range> | Range of slides to export (e.g. 1-3,5,8) |
--headless | Puppeteer headless mode: new, true, false [new] |
--headers | Comma-separated <header>,<value> pairs |
--chrome-path <path> | Path to Chromium/Chrome executable |
--chrome-arg <arg> | Additional Chrome arguments (can be repeated) |
--pdf-author <arg> | PDF author string |
--pdf-title <arg> | PDF title string |
--pdf-subject <arg> | PDF subject string |
You can use the --slides flag to export only a subset of the presentation. The range follows a pattern of slide indexes and ranges separated by commas.
Example formats:
1-3: Slides 1, 2, and 3.5: Only slide 5.1-3,5,8: Slides 1, 2, 3, 5, and 8.CLI Command:
decktape https://example.com slides.pdf --slides 1-3,5,8To capture each slide as an image instead of (or in addition to) a PDF, use the --screenshots flag. You can configure the resolution, format, and directory using the following options:
--screenshots-directory <dir>: Output directory (default: screenshots).--screenshots-size <size>: Resolution (e.g., 1280x720). This can be repeated to capture multiple resolutions.--screenshots-format <format>: Image format, either jpg or png (default: png).Example: Capturing multiple resolutions
$ decktape --screenshots --screenshots-size=400x300 --screenshots-size=800x600 <url> <filename>$ decktape --screenshots --screenshots-size=400x300 --screenshots-size=800x600Use the --slides option to export only a subset of the presentation. You can provide individual slide indexes, ranges, or a combination of both.
Examples:
--slides 1--slides 1,3,5--slides 1-10--slides 1,2,5-10