@modernice/pdf-tool-server
v0.1.0
Published
A collection of PDF tools packed in a Node.js webserver.
Downloads
2
Readme
PDF Tool Server
A collection of PDF tools packed in a Node.js webserver.
Setup
- Copy environment file
cp .env.example .env
- Install dependencies
yarn
- Build
yarn build
- Start server
yarn start
Usage
Create PDF from a webpage
Send a POST request to '/page-to-pdf' with the following options as JSON and save the returned data as a PDF file to your disk.
| Option | Required | Default | Type | Description |
| ------ | -------- | ------- | ---- | ----------- |
| url
| yes | - | string
| URL to the webpage |
| selector
| no | - | string
| DOM selector (only use contents of this element) |
| waitUntil
| no | 'networkidle0'
| 'networkidle0'
'networkidle0'
'networkidle2'
'load'
'domcontentloaded'
| Page event that determines when the page has been loaded |
| waitForSelector
| no | - | string
| DOM selector (wait for the element to appear before capturing the page) |
| delay
| no | - | integer
| Delay caputure for given milliseconds after the page has loaded |
| format
| no | 'A4'
| 'Letter'
'Legal'
'Tabloid'
'Ledger'
'A0'
'A1'
'A2'
'A3'
'A4'
'A5'
| The PDF size |
| authToken
| no | - | string
| Used as authorization header when requesting the URL |
| viewport.width
| no | 1920
| integer
| Set the viewport width of the browser window |
| viewport.height
| no | 1080
| integer
| Set the viewport height of the browser window |