Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dills122/weasyprint-wrapper

weasyprint node wrapper
https://github.com/dills122/weasyprint-wrapper

cli-wrapper nodejs pdf pdf-generator weasyprint wrapper

Last synced: 8 days ago
JSON representation

weasyprint node wrapper

Awesome Lists containing this project

README

        

# Weasyprint Wrapper

[![CodeFactor](https://www.codefactor.io/repository/github/dills122/weasyprint-wrapper/badge)](https://www.codefactor.io/repository/github/dills122/weasyprint-wrapper)

A node wrapper module for use with the weasyprint cli

This module was a copy of this [repo](https://github.com/tdzienniak/node-weasyprint) with minor updates and reuploaded back to npm.

To install

```
npm i weasyprint-wrapper
```

Example use

```javascript
const weasyprint = require('weasyprint-wrapper');

//specify the location of weasyprint cli if not in PATH
weasyprint.command = '~/programs/weasyprint';

// URL
weasyprint('http://google.com/', { pageSize: 'letter' })
.pipe(fs.createWriteStream('out.pdf'));

// HTML
weasyprint('

Test

Hello world

')
.pipe(res);

// Stream input and output
var stream = weasyprint(fs.createReadStream('file.html'));

// output to a file directly
weasyprint('http://apple.com/', { output: 'out.pdf' });

// Optional callback
weasyprint('http://google.com/', { pageSize: 'letter' }, function (err, stream) {
// do whatever with the stream
});
```