npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

slide2pdf

v1.0.0

Published

Module to convert slides to PDF

Downloads

3

Readme

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 :
    • example :
file:///home/myDir/presentation.html#slide1

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.

  • 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