weasyprint

0.1.7 • Public • Published

weasyprint

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

This module is a fork of dills122/weasyprint-wrapper with fixes, minor updates and reuploaded back to npm as weasyprint.

Getting started

Install the package (Python3 required):

pip3 install weasyprint

Add this NodeJS wrapper to your project:

npm i weasyprint

Usage

Example:

const weasyprint = require('weasyprint');

// 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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.7
    46
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.7
    46
  • 0.1.6
    1
  • 0.1.5
    1
  • 0.1.4
    2

Package Sidebar

Install

npm i weasyprint

Weekly Downloads

44

Version

0.1.7

License

MIT

Unpacked Size

6.41 kB

Total Files

9

Last publish

Collaborators

  • bob6664569