@makinacorpus/slide2pdf
Module to convert slides to PDF
Last updated a year ago by makinacorpus .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @makinacorpus/slide2pdf 
SYNC missed versions from official npm registry.

slide2pdf

slide2pdf is made to convert WEB presentation slides to PDF by capturing screenshots and converting it to PDF format.

System requirements

  • ImageMagick needs to be installed on your machine (version 6.8.9-9 or greater)
  • Slides need to be online or in a file on your machine

Other requirements

  • Slides given to slide2pdf can't be in PDF format.
  • If slides are locally saved , ensure the URL given to slide2pdf is in a valid format :
    • example :
file:///home/myDir/presentation.html#slide1

Installation

Once you've installed ImageMagick, install the module slide2pdf :

$ npm install -g slide2pdf

You can now use it from any workspace.

Usage

There are two ways to configure app's options. Running the app with no config.json file will launch ReavealJS / Landslide conversion from given url. For instance :

slide2pdf -u https://darekkay.github.io/presentations/accessible-web/index.html#/ -o test.pdf 

Both ways need at least one parameter : the url of the targeted slides.

Configuration file:

To use the configuration file method, you have to launch the application in the shell as follows :

slide2pdf --config <path to the configuration file>

This file has to be a JSON file. The syntax of the configuration file has to be as follows :

{
  "endCase": {
        "operator": "and",
        "reverse": true,
        "queries": [
            ".slide.future",
            ".slide.far-future"
        ]
    },  
  "navigate": [
        [".navigate-down.enabled", "ArrowDown"],
        [".navigate-right.enabled", "ArrowRight"]
  ],
  "colored": true,
  "pictureQuality": 90,
  "outputPath": "./out.pdf",
  "verbose": true,
  "overwrite": false,
  "debug": false,
  "width": 1020,
  "height": 760,
  "animationDelay": 500 ,
  "url": "https://darekkay.github.io/presentations/accessible-web/index.html#/"
}

endCase is the option that allows you to choose stopping conditions. Those conditions are selectors that mark the end of the slide by their presence or absence. For instance, the html code of the last slide is characterized by the absence of the class "future"; that's the case that you can see in the example above. If endCase option is missing, stopping conditions for RevealJS and Landslide slides will be used.

  • operator :

    • "and" if you want all queries wrote in queries part to be verified.
    • "or" if you want at least one of the queries to be verified.
  • reverse :

    • Must be true if the absence of querie selector is the sign of the end of the slide.
    • Must be false if the presence of querie selector is the sign of the end of the slide.
  • queries : One or several selectors that must be present/absent to mark the end of the slide.

navigate :

Option where you specify how to navigate from one slide to another. For each case of navigation, you must fill the table with table of size 2. The first cell will contain the selector that lead to the movement expressed in the second cell. For instance, in the example above, each time the HTML code contains the class '.navigate-down.enabled' , the action 'press the arrow right' of the keyboard will be done. You can see the list of supported actions here. The first navigation case specified will be have priority over next ones. Still on the same example, ArrowDown will have the priority over ArrowRight if both selectors are contained in the page. If navigate option is missing, default will be ArrowRight on each slide.

colored is the option allowing to see the app's proceeding information in color. Default is true.

pictureQuality : Describes the quality of the screenshot of the slides. Default is 90.

outputPath : Relative or absolute path where the rendered PDF will be saved. Default is "./out.pdf"

verbose : true if you want to see processing informations in the shell

overwrite :

  • true if you want to overwrite the potential file that has the same name as outputPath
  • false otherwise

Default is false.

debug :

  • true if you want more information when a bug occurs .
  • false otherwise.

width : interger representing the width of the screenshot of slides. Default is 1020.

height : integer reprensenting the height of the screenshot of slides. Default is 760.

animationDelay : integer describing the time (millisecond) you want to wait between the moment that the page is loaded and the screenshot. Usefull if the slide contains animations. Default is 500.

url : url of the slide that you want to convert. Required either in configuration file, or in command line when the app is launched.

Command line options:

A help is provided as so :

Usage: slide2pdf --url <your_url> [options]
 or
 slide2pdf --config <configFile.json> [options]

Options:
  --help                Show help                                      [boolean]
  --version             Show version number                            [boolean]
  -u, --url             URL of the original slides                      [string]
  -q, --picturequality  Quality of the rendered PDF                     [number]
  -w, --width           Width of the rendered PDF                       [number]
  -h, --height          Height of the rendered PDF                      [number]
  -o, --outputpath      Path and name to save the rendered PDF          [string]
  -v                    Verbose mode to detail execution
                                                      [boolean] [default: false]
  --overwrite           To force overwriting chosen file
                                                      [boolean] [default: false]
  -d, --debug           To display complementary information when bug occurs
                                                      [boolean] [default: false]
  --config              Path to configuration file.
                                             [string] [default: "./config.json"]
  --delay               Delay needed to skip animations                 [number]

Command line options will have priority over configuration file. As an example, if you specified a different url in your config file than in command line, the url given in command line will be the targeted one.

Tech

slide2pdf uses a number of open source projects to work properly:

  • NodeJS - Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine (V7.6.0 or greater)
  • ImageMagick
  • All packages listed in package.json file

Current Tags

  • 1.0.0                                ...           latest (a year ago)

1 Versions

  • 1.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 2
Dependencies (12)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |