0.0.5 • Published 11 years ago

pdfkitjs v0.0.5

Weekly downloads
214
License
-
Repository
-
Last release
11 years ago

PDFKitJs

Create PDFs using plain old HTML+CSS. Uses wkhtmltopdf on the back-end which renders HTML using Webkit.

Hightly inspired by PDFKit written in Ruby

Install

PDFKit

npm install pdfkit

wkhtmltopdf

https://github.com/pdfkit/pdfkit/wiki/Installing-WKHTMLTOPDF

Usage

// PDFKit support multiples types (url, file, html) and any options for wkhtmltopdf
// run `wkhtmltopdf --extended-help` for a full list of options
var PDFKit = require('pdfkitjs');

pdf = new PDFKit('url', 'http://google.com');

pdf.toFile('google.pdf', function (err, file) {
  console.log('File ' + file + ' written');
});

API

PDFKit(type, url_file_or_html[, options[, spawnOptions, logger]])

options : Object corresponding on wkhtmltopdf arguments. run wkhtmltopdf --extended-help for a full list of options

spawnOptions : Options passed to child_process.spawn

  • url
new PDFKit('url', 'http://google.com')
  • file
new PDFKit('file', 'path/to/some.html')
  • html
new PDFKit('html', '<h1>Hello</h1>')

Logger

You can pass a logger object that implemnts log, warn, debug methods. Default logger:

var baseLogger = {
  log: console.log,
  warn: console.warn,
  debug: console.log
};

To silent all logs, you can pass false.

Output

TODO

Copyright

Copyright (c) 2010 Loïc Mahieu.

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago