Giter Club home page Giter Club logo

wkhtmltopdf's Introduction

wkhtmltox-promise

A simple wrapper for wkhtmltopdf/wkhtmltoimage for ES 2016/2017 using promises. Downloads and installs the latest wkhtmtopdf lib (0.12.4) on linux.

Installation:

npm i wkhtmltox-promise

API:

pdf(source, dest, options)
	returns Promise

image(source, dest, options[, ignore])
	returns Promise

source = any valid URI

dest = any valid URI

options = (optional*) array of arguments passed to wkhtmltopdf / wkhtmltoimage

see [https://wkhtmltopdf.org/usage/wkhtmltopdf.txt] for details.

ignore = (optional*) array( or object of keys) of errors, or string error to ignore in the child. If the substring in the childs stderr, the promise will resolve anyway. This feature is intended to support some wkhtmltox errors that don't prevent the pdf generation from succeeding, but nonetheless report an exit status > 0 and would otherwise reject.

Examples:

PDF

const convert = require("wkhtmltox-promise");

convert.pdf("http://www.google.com", "out.pdf")
	.then(result => {
		var stdout = result.stdout;
        console.log('stdout: ', stdout);
		// do something with out.pdf
    })
    .catch(function (err) {
        console.error('ERROR: ', err, err.stderr);
    });

Image

const convert = require("wkhtmltox-promise");

convert.image("http://www.google.com", "out.png")
	.then(result => {
		var stdout = result.stdout;
        console.log('stdout: ', stdout);
		// do something with out.png
    })
    .catch(function (err) {
        console.error('ERROR: ', err, err.stderr);
    });

Ignoring errors

const convert = require("wkhtmltox-promise");

convert.pdf("http://www.google.com", "out.png", ['--quiet'], ['UnknownContentError'])
	.then(result => {
		var stdout = result.stdout;
        console.log('stdout: ', stdout);
		// do something with out.pdf
    })
    .catch(function (err) {
        console.error('ERROR: ', err, err.stderr);
    });

wkhtmltopdf

wkhtmltopdf's People

Contributors

joelabair avatar thezyppi avatar yuehui avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.