0.1.1 • Published 5 years ago

moleculer-pdf v0.1.1

Weekly downloads
21
License
MIT
Repository
github
Last release
5 years ago

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

PropertyTypeDefaultDescription
puppeteerArgsObject{ headless: true }Set of configurable options to set on the browser
optionsObject{ format: 'letter' }Set of configurable options to set pdf document
remoteContentBooleantrueContent to load on webpage like

Actions

transform

Transform html to pdf document

Parameters

PropertyTypeDefaultDescription
htmlStringrequiredThe html content

Results

Type: Buffer

  • Generated pdf document

Methods

transform

Transform html to pdf document

Parameters

PropertyTypeDefaultDescription
htmlString-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