🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

weasyprint

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

weasyprint

Weasyprint Wrapper for NodeJS (Python PDF Generator from HTML)

0.1.7
latest
Source
npm
Version published
Weekly downloads
194
63.03%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

weasyprint

FAQs

Package last updated on 21 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts