Neverending Perpetual Motion
Learn how companies like Phone2Action are using npm in their front-end developmentJoin the conversation »

moleculer-pdf

0.1.1 • Public • Published

Moleculer logo

Build Status Coverage Status Codacy Badge Code Climate David Known Vulnerabilities Join the chat at https://gitter.im/moleculerjs/moleculer

moleculer-pdf NPM version

Moleculer service to generate PDF

Features

Install

npm install moleculer-pdf --save

Usage

'use strict';
 
let { ServiceBroker } = require("moleculer");
let PDFService = require("../../index");
const { promisify } = require("util");
const { writeFile } = require("fs");
const writeFileAsync = promisify(writeFile);
 
// Create broker
let broker = new ServiceBroker({
  logger: console
});
 
// Load my service
broker.createService(PDFService);
 
// Start server
broker.start().then(() => {
  // Call action
  broker
    .call("pdf.transform", { html: "<h1>John Doe</h1>" })
    .then(buff => writeFileAsync("./pdf.pdf", buff))
    .catch(broker.logger.error);
});

Settings

Property Type Default Description
puppeteerArgs Object { headless: true } Set of configurable options to set on the browser
options Object { format: 'letter' } Set of configurable options to set pdf document
remoteContent Boolean true Content to load on webpage like

Actions

transform

Transform html to pdf document

Parameters

Property Type Default Description
html String required The html content

Results

Type: Buffer

  • Generated pdf document

Methods

transform

Transform html to pdf document

Parameters

Property Type Default Description
html String - The html content

Results

Type: Buffer

  • Generated pdf document

Test

$ npm test

In development with watching

$ npm run ci

Contribution

Please send pull requests improving the usage and fixing bugs, improving documentation and providing better examples, or providing some testing, because these things are important.

License

The project is available under the MIT license.

Contact

Copyright (c) 2019 moleculer-pdf

@icebob @icebob

Install

npm i moleculer-pdf

DownloadsWeekly Downloads

6

Version

0.1.1

License

MIT

Unpacked Size

11.4 kB

Total Files

12

Last publish

Collaborators

  • avatar