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 🙏

© 2026 – Pkg Stats / Ryan Hefner

bespoke-to-pdf

v4.1.3

Published

Generate a PDF file from your bespoke presentation

Readme

bespoke-to-pdf

Generate a PDF file from your bespoke presentation

Requirements

  • Presentation must be using bespoke-hash
    • Unless using a custom app

Usage

Command line

$ npm -g install bespoke-to-pdf
$ bespoke-to-pdf http://localhost:8080 30 > ./out.pdf

Inputs

Simply provide the URL of the presentation, and the amount of slides in the presentation.

bespoke-to-pdf [presentation-url] [slide-count]
bespoke-to-pdf [slide-count] [presentation-url]

Programmatic

$ npm install --save bespoke-to-pdf
var toPdf = require('bespoke-to-pdf');
var fs = require('fs');
var pdfStream = toPdf('http://localhost:8080', 30);

pdfStream.pipe(fs.createWriteStream('./out.pdf'));

The bespoke-to-pdf module returns a function, which takes a presentation url and slide count and returns a PDF stream.

toPdf(presentationUrl<String>, slideCount<Number>, opts<Object>) => Stream

Options

The exported function can be passed a third options parameter to tweak positional, dimensional and time flow settings.

Listed values are defaults

{

  width: 1024 * 1.5,  //width of browser instance
  height: 682 * 1.5,  //height of browser instance
  delay: 5000, // (milliseconds) delay from page load to first capture
  orientation: 'landscape', // PDF paper layout portrait or landscape 
  paperSize: 'A4',  // PDF paper size, accepts common US and GB sizes or an array tuple consisting of [width, height]
  app: undefined, //path to nw.js app, which is passed to nw-shot dependency
  slide: {
    left: 14.5, //left position of the slide in the PDF page
    top: 22, // top position of the slide in the PDF page
    width: 813, // width of the slide in the PDF page
    height: undefined, //height of the slide in the PDF page
    fit: undefined, // Array tuple consisting of [width, height]
                    // fit overrides width and height, causes image
                    // to fit into supplied bounds
    scale: 1, // scale image by amount
    delay: 1000 // delay between slides
  }
}

To pass top level options via the command line simply use their names as flags, e.g.

$ bespoke-to-pdf --delay 1000 http://localhost:8080 30 > ./out.pdf

Access sub level options using a hyphen:

$ bespoke-to-pdf --slide-scale 2 http://localhost:8080 30 > ./out.pdf

Supply command line objects or arrays as JSON, make sure to quote it so spaces don't cause unintended parsing:

$ bespoke-to-pdf --slide-fit "[100, 100]" http://localhost:8080 30 > ./out.pdf

Example

$ bespoke-to-pdf http://davidmarkclements.github.io/10-tips/ 71 > 10-tips.pdf

This will generate a PDF from a remote bespoke presentation, depending on connection and CPU speed the delay may have to be adjusted slightly. Locally hosted presentations that don't use on-load fade-ins are perfectly suited to a lower delay.

Getting a Visual

Set an environment variable NWSHOT_SHOW to 1 to unhide the NW.js browser window taking snapshots.

$ NWSHOT_SHOW=1 bespoke-to-pdf http://localhost:8080 30 > ./out.pdf

Running on a Server

NW.js requires an X server to run, currently there is no headless offering. Until that happens see this comment in NW.js issue 769 for a starting place to create a server environment that will run NW.js without requiring a physical display.

How

bespoke-to-pdf uses a hidden NW.js browser to load the presentation, then uses the Window.capturePage to capture an image of the current slide, moving through the slides by incrementing location.hash. Each captured image is appended to a PDFDocument stream as provided by pdfkit.

License

MIT License

Sponsorship

Sponsored by nearForm