Giter Club home page Giter Club logo

decktape's Introduction

DeckTape

DeckTape is a high-quality PDF exporter for HTML5 presentation frameworks.

DeckTape supports all the features that you would expect from a PDF exporter like font embedding, selectable text, hyperlinks, SVG graphics objects, file compression.

DeckTape is built on top of PhantomJS which relies on Qt WebKit for laying out and rendering Web pages and provides a headless WebKit scriptable with a JavaScript API.

DeckTape currently supports the following presentation frameworks out of the box:

 • Bespoke.js       • DZSlides         • remark           • Shower
 • CSSS             • Flowtime.js      • reveal.js        • Slidy
 • deck.js          • impress.js       • RISE

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.

Install

From the command-line, follow the instructions below:

  1. Shallow clone DeckTape Git repository:

    $ git clone --depth 1 https://github.com/astefanutti/decktape.git
  2. Change into the decktape directory:

    $ cd decktape
  3. Download PhantomJS executable:

    ℹ️
    DeckTape currently depends on a forked version of PhantomJS. What follows is a list of precompiled binaries for various platforms.
     # Windows (MSVC 2013), 64-bit, for Windows Vista or later, bundles VC++ Runtime 2013
     $ curl -L http://astefanutti.github.io/decktape/downloads/phantomjs-msvc2013-win64.exe -o bin\phantomjs.exe
     # Mac OS X (Cocoa), 64-bit, for OS X 10.6 or later
     $ curl -L http://astefanutti.github.io/decktape/downloads/phantomjs-osx-cocoa-x86-64 -o bin/phantomjs
     # Linux (CentOS 6), 64-bit
     $ curl -L http://astefanutti.github.io/decktape/downloads/phantomjs-linux-centos6-x86-64 -o bin/phantomjs
     # Linux (CentOS 7), 64-bit
     $ curl -L http://astefanutti.github.io/decktape/downloads/phantomjs-linux-centos7-x86-64 -o bin/phantomjs
     # Linux (Debian 8), 64-bit
     $ curl -L http://astefanutti.github.io/decktape/downloads/phantomjs-linux-debian8-x86-64 -o bin/phantomjs
     # Linux (Ubuntu 16.04), 64-bit
     $ curl -L http://astefanutti.github.io/decktape/downloads/phantomjs-linux-ubuntu16-x86-64 -o bin/phantomjs
  4. Set the execute permission (non-Windows OS binaries only):

    $ chmod +x bin/phantomjs

If the executable isn’t available for your target platform, follow the instructions in the Build section. Alternatively, DeckTape provides a Docker image so that you can directly execute it with Docker. See the Docker section for more information.

Usage

Inside the DeckTape install directory, run:

$ ./bin/phantomjs decktape.js -h

Usage: phantomjs decktape.js [options] [command] <url> <filename>

command      one of: automatic, bespoke, csss, deck, dzslides, flowtime, generic, impress,
             remark, reveal, shower, slidy
url          URL of the slides deck
filename     Filename of the output PDF file

Options:
   -s <size>, --size <size>        Size of the slides deck viewport: <width>x<height>  (ex. 1280x720)
   -p <ms>, --pause <ms>           Duration in milliseconds before each slide is exported  [1000]
   --load-pause <ms>               Duration in milliseconds between the page has loaded
                                   and starting to export slides  [0]
   --screenshots                   Capture each slide as an image  [false]
   --screenshots-directory <dir>   Screenshots output directory  [screenshots]
   --screenshots-size <size>       Screenshots resolution, can be repeated  [--size]
   --screenshots-format <format>   Screenshots image format, one of [jpg, png]  [png]
   --slides <range>                Range of slides to be exported, a combination of slide indexes
                                   and ranges (e.g. '1-3,5,8')

Defaults to the automatic command.
Iterates over the available plugins, picks the compatible one for presentation at the
specified <url> and uses it to export and write the PDF into the specified <filename>.

In addition to the general options listed above, command specific options can be displayed the following way:

$ ./bin/phantomjs decktape.js <command> -h

Commands

automatic

Iterates over the available plugins, picks the compatible one for presentation at the specified url and uses it to export and write the PDF into the specified filename.

generic

Emulates the end-user interaction by pressing the key with the specified --keycode option and iterates over the presentation as long as:

  1. Any change to the DOM is detected by observing mutation events targeting the body element and its subtree nor

  2. the number of slides exported has reached the specified --max-slides option.

The --keycode value must be one of the PhantomJS page event keys and defaults to Right, e.g.:

$ ./bin/phantomjs decktape.js generic --keycode=Space

Options

--screenshots

Captures each slide as an image at the --screenshots-size resolution, exports it to the --screenshots-format image format and writes the output into the --screenshots-directory directory.

The --screenshots-size option can be set multiple times. For example:

$ ./bin/phantomjs decktape.js --screenshots --screenshots-size=400x300 --screenshots-size=800x600

--slides

Exports only the slides specified as a series of slides indexes and ranges, e.g.:

 # Capture a single slide
 $ ./bin/phantomjs decktape.js --slides 1
 # Capture a series of slides
 $ ./bin/phantomjs decktape.js --slides 1,3,5
 # Capture a range of slides
 $ ./bin/phantomjs decktape.js --slides 1-10
 # Capture a combination of slides and ranges
 $ ./bin/phantomjs decktape.js --slides 1,2,5-10

The rendering stops and the file written out after the largest numbered slide is exported.

Examples

The following slide deck examples have been exported using DeckTape:

HTML5 Presentation Framework Exported PDF

Beyond Rectangles in Web Design

reveal.js 2.6.2

fowd-nyc-2014.pdf (14MB)

Getting Involved in Open Source

reveal.js 3.0.0

opensource-getting-involved.pdf (0.8MB)

Going Further with CDI

Asciidoctor + DZSlides

going-further-with-cdi.pdf (1.8MB)

Transactions for the REST of us

impress.js 0.5.3

soa-cloud-rest-tcc.pdf (10MB)

Deck.js Modern HTML Presentations

deck.js 1.1.0

deck-js-presentation.pdf (1.1MB)

Flowtime.js Presentation Framework

Flowtime.js

flowtime-js-presentation.pdf (7.5MB)

The Official Remark Slideshow

remark 0.11.0

remark-js-slideshow.pdf (0.7MB)

HTML Slidy: Slide Shows in HTML and XHTML

Slidy

html-slidy-presentation.pdf (0.5MB)

CSSS: CSS-based SlideShow System

CSSS

csss-sample-slideshow.pdf (13.5MB)

Shower Presentation Engine

Shower

shower-presentation-engine.pdf (0.4MB)

Welcome our new ES5 Overloards

Bespoke.js

new-es5-overloards.pdf (0.1MB)

Docker

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 -v `pwd`:/pwd astefanutti/decktape http://lab.hakim.se/reveal-js /pwd/slides.pdf
  • Or, to convert an HTML presentation that’s stored on the local file system in the home directory:

     $ docker run --rm -v `pwd`:/pwd -v ~:/home astefanutti/decktape /home/slides.html /pwd/slides.pdf
  • Or, to convert an HTML presentation that’s deployed on the local host:

     $ docker run --rm --net=host -v `pwd`:/pwd astefanutti/decktape http://localhost:8000 /pwd/slides.pdf

It is recommended to use the following options from the docker run command:

--rm

DeckTape is meant to be run as a short-term foreground process so that it’s not necessary to have the container’s file system persisted after DeckTape exits,

-v

to mount a data volume so that DeckTape can directly write to the local file system.

Alternatively, you can use the docker cp command, e.g.:

 # Run docker run without the --rm option
 $ docker run astefanutti/decktape http://lab.hakim.se/reveal-js slides.pdf
 # Copy the exported PDF from the latest used container to the local file system
 $ docker cp `docker ps -lq`:decktape/slides.pdf .
 # Finally remove the latest used container
 $ docker rm `docker ps -lq`

Finally, if you want to execute DeckTape using a local clone of the DeckTape repository in order to take your changes into account, you can run:

 $ docker run --rm -v `pwd`:`pwd` -w `pwd` astefanutti/decktape slides.html slides.pdf

PhantomJS fork

Overview

DeckTape relies on a forked version of PhantomJS, which is maintained as a submodule of this project. The fork primarily adds a printer API to PhantomJS that allows DeckTape to generate a multi-page PDF document. By default, PhantomJS can only produce a single-page PDF for each capture.

Status

Our goal is to get all the patches from this fork merged into the upstream so the fork is no longer required.

The following table documents the patches we’ve made to PhantomJS and tracks the status of getting them merged into the upstream project.

Description Reference to Patch Merge Status

Printer module API

astefanutti/phantomjs@d8bc4b0

❗ todo

Add support for capturing viewport when rendering images (required to capture snapshots properly) ariya/phantomjs#10619

ariya/phantomjs@bfccbd6

✅ merged

Enable outline annotations to be rendered outside printing context (required for clickable hyperlinks with the printer module)

astefanutti/qtwebkit@b83bf93

❕ todo

PDF font embedding fails on Mac 64-bit due to unimplemented methods in QCoreTextFontEngine

ariya/phantomjs#13243

✅ merged

Render anchors as clickable links in PDF documents

Vitallium/qtwebkit@ef91a25

✅ merged

Add support for drawing a hyperlink in QPdfEngine

Vitallium/qtbase@d50c481

✅ merged

PhantomJS default configuration file support (optional)

ariya/phantomjs#13300

🚫 declined

Build

To build the forked version of PhantomJS for DeckTape, you have to execute the following commands from the DeckTape install directory:

  1. Initialize and check out the phantomjs submodule:

    $ git submodule update --init --recursive --remote
  2. Change into the phantomjs directory:

    $ cd phantomjs
  3. Launch the build script:

    $ ./build.py

More information can be found in Compiling PhantomJS from source and in Building Qt 5 from Git.

Plugin API

✏️

decktape's People

Contributors

astefanutti avatar mojavelinux avatar eljefe6a avatar anaderi avatar gavincarr avatar hadim avatar martin-jung avatar ricklupton avatar ssanderson avatar steshaw avatar onetapbeyond avatar oupala avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.