Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/loicmahieu/pdfkitjs
HTML+CSS to PDF in Node.JS
https://github.com/loicmahieu/pdfkitjs
Last synced: 27 days ago
JSON representation
HTML+CSS to PDF in Node.JS
- Host: GitHub
- URL: https://github.com/loicmahieu/pdfkitjs
- Owner: LoicMahieu
- Created: 2013-09-15T20:13:17.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-07-31T07:44:56.000Z (over 7 years ago)
- Last Synced: 2024-11-29T10:01:37.971Z (about 1 month ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 14
- Watchers: 5
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deprecation warning
[![deprecated](http://badges.github.io/stability-badges/dist/deprecated.svg)](http://github.com/badges/stability-badges) This module is old and the API is not really consistent. I recommend you to use: https://github.com/devongovett/node-wkhtmltopdf
# PDFKitJs
Create PDFs using plain old HTML+CSS. Uses [wkhtmltopdf](https://github.com/antialize/wkhtmltopdf) on the back-end which renders HTML using Webkit.
Hightly inspired by [PDFKit](https://github.com/pdfkit/pdfkit) written in Ruby
## Install
### PDFKit
```bash
npm install pdfkitjs
```
### wkhtmltopdf## Usage
```js
// 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`](http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) except `exec` who is the path to the wkhtmltopdf binary. (Default: `wkhtmltopdf`)
* `url`
```js
new PDFKit('url', 'http://google.com')
```* `file`
```js
new PDFKit('file', 'path/to/some.html')
```* `html`
```js
new PDFKit('html', 'Hello
')
```### Logger
You can pass a logger object that implemnts `log`, `warn`, `debug` methods. Default logger:
```js
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.