Sign inSign up

isneezy/pdf-generator

By isneezy

•Updated over 3 years ago

A simple and yet powerful, versatile web service for converting HTML pages, templates, and URLs into

Image
0

100K+

isneezy/pdf-generator repository overview

⁠@isneezy/pdf-generator-service

Build Status Coverage Status npm (tag)

@isneezy/pdf-generator-service is a web service that allows you to easily generate PDFs from a web interface. It uses the @isneezy/pdf-generator⁠ library to generate the PDFs and provides an HTTP API that you can use to generate PDFs from a web application.

The package is available in three forms:

  • as a command line interface
  • as a container image

⁠Installation

⁠Command Line Interface

You can install the package as a command line interface using npm or yarn.

npm install -g @isneezy/pdf-generator-service
yarn global add @isneezy/pdf-generator-service

⁠Container Image

The package is also available as a container image on quay.io⁠. It's suggested to check the available tags here⁠ before pulling the image.

To run the service in a container, you can use the docker run command and specify the necessary environment variables and ports.

For example:

docker run -p 3000:3000 quay.io/isneezy/pdf-generator-service

This command will start the service and make it accessible on port 3000.

⁠Usage

⁠Command Line Interface

To start the service, you can use the pdf-generator-service command.

pdf-generator-service [options]
OptionTypeDefaultDescription
-V, --versionOutput the version number
-p, --portnumber3000Specify the port in which the service will be listening
-c, --corsbooleanfalseEnable CORS (Cross-Origin Resource Sharing)
-l, --log-levelstringinfoSpecify the log level (info, warn, error, silent)

It's important to note that when using the container image, the options should be passed as environment variables.

⁠HTTP API

The service exposes a single endpoint: POST /v1/generate.

You can use this endpoint to generate a PDF by making a POST request with the following options as the request body.

OptionTypeDefaultDescription
gotostringURL to the HTML content/handlebars template to be converted to PDF. If set this takes priority over template option
templatestringHandlebars template to be converted to PDF
headerTemplatestringHandlebars template to be rendered as page header
footerTemplatestringHandlebars template to be rendered as page footer
contextobject{}Data to be passed to the HTML template
formatstringA4Sets paper format type to be used when printing a PDF (default: "A4")
landscapebooleanfalseUse this flag to switch the orientation from portrait to landscape (default: false)
marginobject{top: "10mm", bottom: "10mm", left: "10mm", right: "10mm"}Set the page margins (default: "10mm")

Tag summary

Content type

Image

Digest

sha256:03778497a…

Size

231.2 MB

Last updated

over 3 years ago

docker pull isneezy/pdf-generator