@hdai-eason/gotenberg-client
v1.0.2
Published
Gotenberg is a pdf converter server, this is a thin client to call Gotenberg API. ## Prerequisite A callable gotenberg endpoint, default to http://localhost:3000 You can run a docker container, please reference https://github.com/gotenberg/gotenberg ##
Readme
Gotenberg Client
Gotenberg is a pdf converter server, this is a thin client to call Gotenberg API.
Prerequisite
A callable gotenberg endpoint, default to http://localhost:3000
You can run a docker container, please reference https://github.com/gotenberg/gotenberg
Get Started
install
npm install @hdai-eason/gotenberg-clientusage
import { GotenbergClient } from '@hdai-eason/gotenberg-client';
const client = new GotenbergClient();
const resultPdf = await client.mdToPdfBuffer("## Introduction\n\nHello, World!\n\n");APIs
class GotenbergClient
constructor(args?: ConstructorArgs)
args?: ConstructorArgs:serverUrl?: string: Gotenberg server url, default to http://localhost:3000,htmlTemplate?: string: The html go template. There is a default value, or you can use your own. if you want to use your own, remember to useinput.mdas markdown name. learn more
mdToPdfBuffer(md: string): Promise<Buffer>
convert a md string to pdf buffer.
md: string: the markdown content, NOT THE FILE PATH.return: Promise<Buffer>: the pdf in binary buffer.
Environment Variable
GOTENBERG_URL=http://localhost:3000Docker Compose
You can simply include, this will use default port 3000:
include:
- 'node_modules/@hdai-eason/gotenberg-client/docker-compose.yml'or extends and override:
services:
gotenberg:
extends:
file: 'node_modules/@hdai-eason/gotenberg-client/docker-compose.yml'
service: gotenberg
ports: !override
- 3003:3000Remark
Server URL Configuration Priority
constructor({serverUrl})process.env.GOTENBERG_URL- Default:
http://localhost:3000
