在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:astefanutti/decktape开源软件地址:https://github.com/astefanutti/decktape开源编程语言:JavaScript 96.5%开源软件介绍:DeckTapeDeckTape is a high-quality PDF exporter for HTML presentation frameworks. DeckTape is built on top of Puppeteer which relies on Google Chrome for laying out and rendering Web pages and provides a headless Chrome instance scriptable with a JavaScript API. DeckTape currently supports the following presentation frameworks out of the box: Bespoke.js • deck.js • DZSlides • Flowtime.js • impress.js • Inspire.js • NueDeck • remark • reveal.js • RISE • Shower • Slidy • WebSlides DeckTape also provides a generic command that works by emulating the end-user interaction, allowing it to be used to convert presentations from virtually any kind of framework. The generic mode is particularly useful for supporting HTML presentation frameworks that don’t expose an API or accessible state. DeckTape’s plugin-based architecture exposes an extension API, making it possible to add support for other frameworks or to tailor existing plugins to your specific needs. DeckTape can optionally be used to capture screenshots of your slide decks in various resolutions (similar to pageres). That can be useful to make sure your presentations are responsive or to create handouts for them. You can browse some slide deck examples below that have been exported with DeckTape. InstallNPMInstall DeckTape globally and run it: $ npm install -g decktape
$ decktape Or locally: $ npm install decktape
$ `npm bin`/decktape See the FAQ for troubleshooting / alternatives. Usage
In addition to the general options listed above, command specific options can be displayed the following way: $ decktape <command> -h Commands
|
HTML5 Presentation | Framework | Exported PDF |
---|---|---|
reveal.js |
reveal-js-demo.pdf (2.0MB) |
|
reveal.js |
devoxx-es6-maintenant.pdf (2.3MB) |
|
reveal.js |
reveal-js-mathjax.pdf (0.3MB) |
|
reveal.js |
opensource-getting-involved.pdf (0.6MB) |
|
Asciidoctor + DZSlides |
going-further-with-cdi.pdf (2.4MB) |
|
deck.js |
deck-js-presentation.pdf (0.5MB) |
|
remark |
remark-js-slideshow.pdf (0.15MB) |
|
remark |
remark-js-coloured-terminal.pdf (0.12MB) |
|
Slidy |
html-slidy-presentation.pdf (0.5MB) |
|
Inspire.js |
inspirejs-sample-slideshow.pdf (1.9MB) |
|
Shower |
shower-presentation-engine.pdf (0.6MB) |
|
Bespoke.js |
new-es5-overloards.pdf (0.2MB) |
|
Spectacle |
DeckTape can be executed within a Docker container from the command-line using the astefanutti/decktape
Docker image available on Docker Hub:
$ docker run astefanutti/decktape -h
For example:
To convert an online HTML presentation and have it exported into the working directory under the slides.pdf
filename:
$ docker run --rm -t -v `pwd`:/slides astefanutti/decktape https://revealjs.com/demo/ slides.pdf
Or, to convert an HTML presentation that’s stored on the local file system in the home
directory:
$ docker run --rm -t -v `pwd`:/slides -v ~:/home/user astefanutti/decktape /home/user/slides.html slides.pdf
Or, to convert an HTML presentation that’s deployed on the local host:
$ docker run --rm -t --net=host -v `pwd`:/slides astefanutti/decktape http://localhost:8000 slides.pdf
You may have to use host.docker.internal
instead of localhost
on macOS and Windows.
You may want to specify a tag corresponding to a released version of DeckTape for the Docker image, e.g. astefanutti/decktape:3.0.0
.
Besides, it is recommended to use the following options from the docker run
command:
Alternatively, you can use the docker cp
command, e.g.:
# Run docker run without the --rm option
$ docker run astefanutti/decktape https://revealjs.com slides.pdf
# Copy the exported PDF from the latest used container to the local file system
$ docker cp `docker ps -lq`:slides/slides.pdf .
# Finally remove the latest used container
$ docker rm `docker ps -lq`
If your presentation relies on fonts installed on the host system, but not in the base Docker container, you can mount your fonts directory as a volume, e.g. for macOS:
$ docker run -v "${HOME}/Library/Fonts:/home/node/.local/share/fonts" ...
I’m using Arch Linux, is there an AUR package?
Yes, it is available at https://aur.archlinux.org/packages/nodejs-decktape/.
Is it possible to pass arguments to Chrome?
Yes, you can use the --chrome-arg
option, e.g.:
$ decktape ... \
--chrome-arg=--proxy-server="proxy:8080" \
--chrome-arg=--allow-file-access-from-files
The list of Chromium flags can be found here.
No usable sandbox!
Arch Linux, among other Linux distributions may have the user namespace in the kernel disabled by default. You can verify this by accessing chrome://sandbox in your chrom[e|ium] browser. You can find more about sandboxing, here. As a temporary work-around, you can pass --chrome-arg=--no-sandbox
as a CLI option.
Failed to read the 'rules' property from 'CSSStyleSheet': Cannot access rules
Starting Chromium 64, accessing CSS rules in a stylesheet loaded from the local filesystem or an external location violates CORS policies.
As some Decktape plugins tweak the CSS rules for better PDF printing, you need to allow access to local files or external stylesheets by setting the --disable-web-security
flag option, e.g.:
$ decktape ... --chrome-arg=--disable-web-security
Layout inconsistencies
Decktape relies on Pupeteer to convert each slide in PDF format. Slight layout inconsistencies can result as part of this transformation. One workaround is to set a specific slide size using the -s
option. The value of -s 1024x768
has generally worked well in such situations.
Reveal.js slide generation never finishes
Decktape does not use the built-in PDF support of reveal.js, and instead captures each slide individually. Therefore you must not append ?print-pdf
or load the print stylesheets in any other way when using Decktape.
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论