Skip to content

sonidelav/nest-micro-pdf-service

Repository files navigation

PDF Microservice

Nest Logo puppeteer

Description

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

Installation

yarn install

Running the app

# development
yarn start

# watch mode
yarn start:dev

# production mode
yarn start:prod

Test

# unit tests
yarn test

# e2e tests
yarn test:e2e

# test coverage
yarn test:cov

Usage

URL 2 PDF

POST http://localhost:3000/pdf/render-url
{
    "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

POST http://localhost:3000/pdf/render-html
{
    "html": "<h1>.....",                  // 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.
        }
    }
}