0.1.11 • Published 4 months ago

@quphoria/weasyprint-wrapper v0.1.11

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

weasyprint

A NodeJS wrapper module for Weasyprint Python package (HTML to PDF converter).

This module is a fork of Trim/weasyprint-wrapper uploaded to npm as weasyprint due to both weasyprint-wrapper and weasyprint still not supporting passed in options, so I have uploaded the patch in Trim's pull request to weasyprint.

Yeah, I know, It's confusing.

Getting started

Install the package (Python3 required):

pip3 install weasyprint

Add this NodeJS wrapper to your project:

npm i @quphoria/weasyprint-wrapper

Usage

Example:

const weasyprint = require('@quphoria/weasyprint-wrapper');

// URL, specifying the format & default command to spawn weasyprint
const resBuffer = await weasyprint('http://google.com/', { 
    command: '~/programs/weasyprint',
    pageSize: 'letter'
});
  
// HTML
const resbuffer = await weasyprint('<h1>Test</h1><p>Hello world</p>');

// Save in a file
try {
    const buffer = await weasyprint('<h1>Test</h1><p>Hello world</p>');
    fs.writeFileSync('test.pdf', buffer);
} catch (err) {
    console.error(err);
}

License

MIT

0.1.11

4 months ago

0.1.10

4 months ago

0.1.9

4 months ago

0.1.8

4 months ago

0.1.7

4 months ago