Documentation

Learn how to use RenderKit's JSON-based API to generate beautiful PDFs with our building blocks system.

Quick Start

Make an API Request

Send a POST request to our API with your JSON data to generate a PDF.

curl --request POST \
  --url https://api.renderkit.app/pdf/render \
  --header 'content-type: application/json' \
  --header 'x-api-key: YOUR_API_KEY' \
  --data '{
    "document": {
        "title": "Testing title",
        "filename": "test.pdf",
        "author": "Testing author",
        "creator": "Test creator"
    },
    "pages": [
        {
            "type": "page",
            "props": {
                "size": "A4",
                "orientation": "portrait",
                "padding": 24,
                "blocks": [
                    {
                        "type": "text",
                        "props": {
                            "text": "Hello, World!"
                        }
                    }
                ]
            }
        }
    ]
}' > test.pdf

JSON Structure

data
RenderKit uses a simple JSON structure to define PDF layouts. Each PDF consists of pages, and each page contains building blocks.
{
  "document": {},
  "pages": []
}

Properties

PropertyTypeRequiredDescription
documentobjectYesDocument object
pagesarrayYesArray of page objects

Document

document
The document object contains metadata about the PDF document.
{
  "title": "My Document",
  "filename": "my-document.pdf",
  "author": "John Doe",
  "creator": "RenderKit",
  "subject": "My Document",
  "language": "en"
}

Properties

PropertyTypeRequiredDescription
titlestringNoDocument title
filenamestringNoDocument filename
authorstringNoDocument author
creatorstringNoDocument creator
subjectstringNoDocument subject
languagestringNoDocument language

Page

page
A page object contains the building blocks that make up the page.
{
  "type": "page",
  "props": {
    "size": "A4",
    "orientation": "portrait",
    "padding": 24,
    "backgroundColor": "#fff",
    "blocks": [
      {
        "type": "text",
        "props": {
          "text": "Hello",
          "size": "16",
          "color": "#000000"
        } 
      }
    ]
  }
}

Properties

PropertyTypeRequiredDescription
sizestringNoPage size (A4, Letter, etc.) (optional)
orientation"portrait" | "landscape"NoPage orientation (optional)
paddingnumberNoPage padding (optional)
backgroundColorstringNoBackground color (optional)
blocksarrayNoArray of blocks (optional)

Building Blocks

Building blocks are the core components you use to create PDF layouts. Each block has a specific purpose and accepts different properties.

Text

text
Display text content with customizable styling options.
{
  "type": "text",
  "props": {
    "text": "Hello, World!",
    "size": "16",
    "color": "#000000"
  }
}

Properties

PropertyTypeRequiredDescription
textstringYesThe text to display
sizestringNoFont size (optional)
colorstringNoText color (optional)

Image

image
Display images from URLs with size options.
{
  "type": "image",
  "props": {
    "src": "https://example.com/image.jpg",
    "width": 200,
    "height": 150
  }
}

Properties

PropertyTypeRequiredDescription
srcstringYesImage URL
widthnumberYesImage width (px)
heightnumberYesImage height (px)

Table

table
Create structured data tables with headers and rows.
{
  "type": "table",
  "props": {
    "headers": [
      { "key": "name", "label": "Name" },
      { "key": "email", "label": "Email" }
    ],
    "rows": [
      ["John Doe", "john@example.com"],
      ["Jane Smith", "jane@example.com"]
    ]
  }
}

Properties

PropertyTypeRequiredDescription
headersarrayYesArray of header objects ({ key, label, width?, align? })
rowsarrayYesArray of table rows (arrays of strings/numbers)

Stack

stack
Group multiple blocks together with consistent spacing.
{
  "type": "stack",
  "props": {
    "type": "column",
    "align": "center",
    "gap": 8,
    "blocks": [
      { "type": "text", "props": { "text": "Item 1" } },
      { "type": "text", "props": { "text": "Item 2" } }
    ]
  }
}

Properties

PropertyTypeRequiredDescription
type"row" | "column"YesStack direction
alignstringNoAlignment (optional)
gapnumberNoGap between blocks (optional)
flexnumberNoFlex value (optional)
paddingVerticalnumberNoVertical padding (optional)
paddingHorizontalnumberNoHorizontal padding (optional)
blocksarrayNoArray of blocks (optional)

Divider

divider
Add horizontal lines to separate content sections.
{
  "type": "divider",
  "props": {
    "marginVertical": 8,
    "borderColor": "#e0e0e0",
    "borderWidth": 1
  }
}

Properties

PropertyTypeRequiredDescription
marginVerticalnumberNoVertical margin (optional)
borderColorstringNoBorder color (optional)
borderWidthnumberNoBorder width (optional)

Spacer

spacer
Add vertical or horizontal space between elements.
{
  "type": "spacer",
  "props": {
    "size": 20,
    "direction": "vertical"
  }
}

Properties

PropertyTypeRequiredDescription
sizenumberYesSpace size in px
direction"vertical" | "horizontal"NoDirection (optional)