Skip to content

Quick Examples

These are copy-ready examples for POST /api/v1/render.

If you want to run them in the browser, open API Console.

10-second start

Run this example in API Console

Use this first to confirm your token, endpoint, and basic PDF generation path.

bash
curl -X POST "https://gpdf.example.com/api/v1/render" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -H "X-Request-Id: quickstart-001" \
  --data-binary '{
    "pages": [
      {
        "size": "label_100_150",
        "elements": [
          {
            "type": "text",
            "x": 10,
            "y": 18,
            "content": "Hello gPdf"
          }
        ]
      }
    ]
  }' \
  --output quickstart.pdf

Run this example in API Console

This sample is a better real-world starting point than the minimal example. It includes:

  • global defaults
  • header / footer
  • text
  • barcode
  • image asset shorthand
json
{
  "settings": {
    "defaults": {
      "text": {
        "font_family": "NotoSans-Regular",
        "font_size": 10.5,
        "color": "#111827"
      },
      "stroke": {
        "color": "#111827",
        "width": 0.3
      }
    },
    "output": {
      "mode": "file",
      "file_name": "shipping-label.pdf"
    }
  },
  "header": {
    "height": 10,
    "elements": [
      {
        "type": "text",
        "x": 8,
        "y": 6,
        "content": "PDN EXPRESS"
      }
    ]
  },
  "footer": {
    "height": 8,
    "elements": [
      {
        "type": "text",
        "x": 8,
        "y": 4,
        "content": "Page ",
        "style": {
          "width": 30
        }
      }
    ]
  },
  "pages": [
    {
      "size": "label_100_150",
      "elements": [
        {
          "type": "image",
          "x": 8,
          "y": 12,
          "width": 18,
          "height": 8,
          "asset": "pdn_express_logo",
          "format": "jpg"
        },
        {
          "type": "text",
          "x": 8,
          "y": 26,
          "content": "Order #SO-20260415-001",
          "style": {
            "font_size": 11,
            "font_weight": "bold"
          }
        },
        {
          "type": "barcode",
          "x": 8,
          "y": 34,
          "width": 58,
          "height": 18,
          "format": "code128",
          "content": "SO-20260415-001",
          "barcode_text": {
            "enabled": true
          }
        },
        {
          "type": "rect",
          "x": 8,
          "y": 56,
          "width": 84,
          "height": 28,
          "stroke": {
            "color": "#D1D5DB",
            "width": 0.3
          }
        },
        {
          "type": "text",
          "x": 12,
          "y": 62,
          "content": "Recipient: Alex Chen"
        },
        {
          "type": "text",
          "x": 12,
          "y": 70,
          "content": "Address: 88 Harbor Road, Shanghai"
        }
      ]
    }
  ]
}

Image examples

Asset shorthand

Load this example in API Console

json
{
  "type": "image",
  "x": 4,
  "y": 8,
  "width": 15,
  "height": 6.5,
  "asset": "pdn_express_logo",
  "format": "jpg"
}

Explicit Base64 source

Load this example in API Console

json
{
  "type": "image",
  "x": 4,
  "y": 8,
  "width": 15,
  "height": 6.5,
  "source": {
    "kind": "base64",
    "format": "jpg",
    "payload": "/9j/4AAQSkZJRgABAQ..."
  }
}

Text examples

Plain text shorthand

json
{
  "type": "text",
  "x": 10,
  "y": 20,
  "content": "Hello gPdf"
}

spans shorthand

json
{
  "type": "text",
  "x": 10,
  "y": 20,
  "content": {
    "spans": [
      { "text": "Order ", "style": { "font_weight": "bold" } },
      { "text": "#SO-20260415-001" }
    ]
  }
}

Block text

Load this example in API Console

json
{
  "type": "text",
  "x": 10,
  "y": 20,
  "frame": {
    "width": 60
  },
  "defaults": {
    "run": {
      "font_family": "NotoSans-Regular",
      "font_size": 10.5,
      "color": "#111827"
    }
  },
  "content": {
    "blocks": [
      {
        "type": "paragraph",
        "inlines": [
          { "type": "text", "text": "Hello " },
          { "type": "text", "text": "gPdf", "style": { "font_weight": "bold" } }
        ]
      }
    ]
  }
}

Next step

After the quick start succeeds: