slide2PDF
slide2PDF is a simple app developped with JavaScript and NodeJS. This app is made to convert your slides to PDF.
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 :
file:///home/myDir/presentation.html
Installation
Once you've installed ImageMagick, install the module slide2PDF :
$ npm install slide2pdf
You can now use it from any workspace.
Usage
There are two way 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 way 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 so :
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, default will be stopping conditions for RevealJS and Landslide slides.
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