https://github.com/olivmonnier/moleculer-pdf
Moleculer service to generate PDF
https://github.com/olivmonnier/moleculer-pdf
microservices moleculer pdf puppeteer
Last synced: 6 months ago
JSON representation
Moleculer service to generate PDF
- Host: GitHub
- URL: https://github.com/olivmonnier/moleculer-pdf
- Owner: olivmonnier
- License: mit
- Created: 2019-09-13T15:04:09.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T22:38:28.000Z (almost 3 years ago)
- Last Synced: 2025-03-17T04:38:03.761Z (7 months ago)
- Topics: microservices, moleculer, pdf, puppeteer
- Language: JavaScript
- Homepage:
- Size: 563 KB
- Stars: 10
- Watchers: 1
- Forks: 2
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-moleculer - moleculer-pdf - A [Puppeteer](https://github.com/GoogleChrome/puppeteer)-based Moleculer service that generates PDF from HTML. (Services / Others)
README

[](https://travis-ci.org/olivmonnier/moleculer-pdf)
[](https://coveralls.io/github/olivmonnier/moleculer-pdf?branch=master)
[](https://www.codacy.com/app/<---username---->/moleculer-pdf?utm_source=github.com&utm_medium=referral&utm_content=olivmonnier/moleculer-pdf&utm_campaign=Badge_Grade)
[](https://codeclimate.com/github/olivmonnier/moleculer-pdf)
[](https://david-dm.org/olivmonnier/moleculer-pdf)
[](https://snyk.io/test/github/olivmonnier/moleculer-pdf)
[](https://gitter.im/moleculerjs/moleculer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)# moleculer-pdf [](https://www.npmjs.com/package/moleculer-pdf)
Moleculer service to generate PDF
## Features
## Install
```
npm install moleculer-pdf --save
```## Usage
```js
'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: "John Doe
" })
.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](https://tldrlegal.com/license/mit-license).# Contact
Copyright (c) 2019 moleculer-pdf[](https://github.com/moleculerjs) [](https://twitter.com/Icebobcsi)