Skip to content

ahmedshabib/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

$ npm install

Running the app

# development
$ npm run start

# watch mode
$ npm run start:dev

# production mode
$ npm run start:prod

Test

# unit tests
$ npm run test

# e2e tests
$ npm run test:e2e

# test coverage
$ npm run 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.
        }
    }
}

About

PDF Microservice based on NestJS

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 78.2%
  • HTML 9.5%
  • JavaScript 8.3%
  • Dockerfile 3.5%
  • Shell 0.5%