Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/dills122/weasyprint-wrapper
- Owner: dills122
- License: mit
- Created: 2019-09-25T02:59:06.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-01-14T04:24:44.000Z (about 3 years ago)
- Last Synced: 2024-10-15T02:32:03.956Z (4 months ago)
- Topics: cli-wrapper, nodejs, pdf, pdf-generator, weasyprint, wrapper
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 4
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
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
});
```