0.1.1 • Published 6 years ago
moleculer-pdf v0.1.1

moleculer-pdf 
Moleculer service to generate PDF
Features
Install
npm install moleculer-pdf --saveUsage
'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 testIn development with watching
$ npm run ciContribution
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