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: 5 months 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 (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-14T04:24:44.000Z (almost 4 years ago)
- Last Synced: 2025-07-01T04:01:51.992Z (6 months ago)
- Topics: cli-wrapper, nodejs, pdf, pdf-generator, weasyprint, wrapper
- Language: JavaScript
- Homepage:
- Size: 7.81 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Weasyprint Wrapper
[](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
});
```