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

wkhtmltopdf-nodejs-options-wrapper

v1.0.7

Published

Wkhtmltopdf options wrapper for node js

Downloads

14

Readme

wkhtmltopdf-nodejs-options-wrapper

A wrapper of wkhtmltopdf options.

Usage

It can be used in a client for wkhtmltopdf-nodejs-ws-server (it has to be started) with webpack like following:

1. Install from npm:

  • webpack,
  • wkhtmltopdf-nodejs-options-wrapper,
  • socket.io-client.

2. Create client.js file with contents:

var wkhtmlToPdf = require('wkhtmltopdf-nodejs-options-wrapper'),
    io = require('socket.io-client');

var socket = io('http://192.168.33.125:3000'); //<-address of websocket server.

var page = new wkhtmlToPdf.Page(),
    request = new wkhtmlToPdf.CreateRequest();

//let's generate pdf from google page
page.setInput('http://google.com');

request.setDebug(true); //all debug output will be returned from server
request.addPage(page);
request.getGlobalOptions().setPageSize('Letter'); //default page size is A4

setTimeout(function() {
    socket.emit('create', request.toObject());

    socket.on('pdf:create:success', function(response) {
        console.log('Pdf created: http://192.168.33.125:3000/result_' + response.handle + '.pdf');
        console.log(response);

        // later we can delete pdf: socket.emit('delete', response.handle);
    });

    socket.on('pdf:create:fail', function(response) {
        console.log('Pdf creation failed!');
        console.log(response);
    });
}, 2000);

3. Create webpack.config.js file with webpack configuration:

module.exports = {
    entry: "./client.js",
    output: {
        path: __dirname,
        filename: "compiled.js"
    }
};

4. Compile client.js

Run webpack command from the folder where client.js and webpack.config.js are located. It will create compiled.js file that can be used in html script tag.

5. Finish

Include compiled.js script to any html file and open it in any brower.

After steps 1-5 are done pdf with google page will be generated and you will see link to it in js debugger.

Running tests

To run unit tests you can use npm test command.