Generating images

This guide explains how to create image templates and generate images using PDFMonkey.

With the release of Engine v5, PDFMonkey can now generate images. In this guide we will look at the creation of image templates and documents that use them.

Image Templates

In order to generate images, you need to create an image Template. You can do so by selection the "Image" output type when creating your template.

Why have separate Template types?

The main reason to have Templates dedicated to images is that PDF and images behave very differently. While PDF documents can have header and footer or various paper formats, image support transparent backgrounds and specific dimensions.

Once your template is created, you can update its settings to set its dimensions and decide if you want to use a transparent background or not.

Generating an image

To generate an image, you simply have to call the API the same way you do to generate a PDF, by calling the POST /api/v1/documents endpoint (or POST /api/v1/documents/sync for sync generation).

By default a webp image will be created. It's a well supported format that provides good quality at a reasonable size and supports transparent background.

Generation-time options

There are a few options you can provide to change the image you generate. They are all provided through the Documents' meta-data:

Request body
{
  "document": {
    "document_template_id": "...",
    "payload": { ... },
    "status": "pending",
    "meta": {
      "_type": "png", // can be webp, png or jpg
      "_width": 123,  // in px
      "_height": 123, // in px
      "_quality": 80  // quality %, only supported by webp (default: 100)
    }
  }
}

Last updated

Was this helpful?