An open API service indexing awesome lists of open source software.

https://github.com/sonidelav/nest-micro-pdf-service

PDF Microservice based on NestJS
https://github.com/sonidelav/nest-micro-pdf-service

html2pdf microservice nestjs pdf puppeteer rest-api typescript

Last synced: 10 days ago
JSON representation

PDF Microservice based on NestJS

Awesome Lists containing this project

README

        

PDF Microservice



Nest Logo
puppeteer

## Description

Is a HTML 2 PDF service powered by NestJS and Puppeteer (Headless Chrome)

## Installation

```bash
yarn install
```

## Running the app

```bash
# development
yarn start

# watch mode
yarn start:dev

# production mode
yarn start:prod
```

## Test

```bash
# unit tests
yarn test

# e2e tests
yarn test:e2e

# test coverage
yarn test:cov
```

## Usage

### URL 2 PDF

```http
POST http://localhost:3000/pdf/render-url
```

```js
{
"url": "https://www.google.gr", // Url to navigate and print to pdf.
"filename": "test.pdf", // Name of file to download.
"json": true, // false to force download stream file.
"options": {
"screen": false, // true for screen media and not print.
"page": {
"format": "A4", // Paper Format (A0, A1, A2 ...).
"landscape": false, // Orientation.
"height": null, // Custom Height of Page.
"width": null // Custom Width of Page.
}
}
}
```

### HTML 2 PDF

```http
POST http://localhost:3000/pdf/render-html
```

```js
{
"html": "

.....", // HTML print when DOMReady event trigged.
"filename": "test.pdf", // Name of file to download.
"json": true, // false to force download stream file.
"options": {
"screen": false, // true for screen media and not print.
"page": {
"format": "A4", // Paper Format (A0, A1, A2 ...).
"landscape": false, // Orientation.
"height": null, // Custom Height of Page.
"width": null // Custom Width of Page.
}
}
}
```