Skip to content

LiquidPDF

Gift voucher with Tailwind, as PDF and PNG

A voucher in the DIN long format, styled with Tailwind classes that are compiled at render time, arbitrary values such as h-[99mm] included. The expiry date is three years after the issue date through dateAdd, the message appears only when there is one, and the same template renders as a PNG for the mail.

Free plan, no card. You get your own copy in the editor, published and ready for the API.

Rendered result

Rendered result: Gift voucher with Tailwind, as PDF and PNG
PDF · 1 page · 34 KB ↓ download

What this example shows

  • tailwind: true compiles the classes the markup uses at render time, arbitrary values such as h-[99mm] and text-[40pt] included; there is no stylesheet.
  • The page is 210mm × 99mm (DIN long) with zero margins, so the gradient runs to the edge.
  • voucher.issued | dateAdd: 3, "years" | date: "dd.MM.yyyy" prints the expiry date 18.09.2029.
  • {% if voucher.message %} leaves the message line out when there is none, and default: "Sie" addresses a voucher without a recipient.
  • output: "png" with settings.image.clipSelector: "main" renders the same template as an image of just the voucher for the mail; output alone would take a 1200 × 630 window with the voucher in its corner. Without either the answer is the PDF for printing.

Helpers used

Template folder

templates/gutschein/template.htmlLiquid
<main class="flex h-[99mm] w-[210mm] bg-gradient-to-br from-indigo-950 via-indigo-800 to-sky-600 text-white">
  <section class="flex flex-1 flex-col justify-between p-[11mm]">
    <p class="text-[8pt] font-semibold uppercase tracking-[0.25em] text-sky-200">Gutschein · {{ shop.name }}</p>
    <div>
      <p class="text-[40pt] font-bold leading-none">{{ voucher.amount | money }}</p>
      <p class="mt-[3mm] text-[11pt] text-sky-100">für {{ voucher.recipient | default: "Sie" }}</p>
      {% if voucher.message %}<p class="mt-[2mm] max-w-[110mm] text-[9.5pt] italic text-sky-100">„{{ voucher.message }}“</p>{% endif %}
    </div>
    <p class="text-[8pt] text-sky-200">
      Ausgestellt am {{ voucher.issued | date: "dd.MM.yyyy" }} · einlösbar bis {{ voucher.issued | dateAdd: 3, "years" | date: "dd.MM.yyyy" }} · {{ shop.url }}
    </p>
  </section>
  <aside class="flex w-[58mm] flex-col items-center justify-center gap-[3mm] bg-white text-slate-900">
    <img class="h-[34mm] w-[34mm]" src="{{ voucher.redeem_url | qrcode: size: 120 }}" alt="Einlöse-Code">
    <p class="font-mono text-[11pt] font-semibold tracking-widest">{{ voucher.code }}</p>
    <p class="text-[7.5pt] text-slate-500">Code im Warenkorb eingeben</p>
  </aside>
</main>
templates/gutschein/settings.jsonJSON
{
  "pdf": {
    "metadata": {
      "title": "Gutschein"
    }
  },
  "paper": {
    "width": "210mm",
    "height": "99mm"
  },
  "margin": {
    "top": "0",
    "right": "0",
    "bottom": "0",
    "left": "0"
  },
  "tailwind": true,
  "locale": "de-DE",
  "timezone": "Europe/Berlin",
  "currency": "EUR"
}
templates/gutschein/data/default.jsonJSON
{
  "shop": {
    "name": "Fennlor Studio",
    "url": "shop.fennlor.example"
  },
  "voucher": {
    "code": "FF-7K2M-9QXA",
    "amount": 50,
    "recipient": "Erika",
    "message": "Alles Gute zum Geburtstag!",
    "issued": "2026-09-18",
    "redeem_url": "https://shop.fennlor.example/einloesen/FF-7K2M-9QXA"
  }
}

Render it through the API

Save the sample data as data.json and send it with the template’s name. Each language uses its SDK; curl sends the same JSON to the REST API, as any other language can. Renders with a key that starts with ff_test_ are not metered; on the Free plan they carry a small watermark.

render.shShell
jq '{template: "gutschein", data: .}' data.json \
  | curl https://api-eu.formfeed.dev/v1/renders \
      -H "Authorization: Bearer ff_test_..." \
      -H "Content-Type: application/json" \
      --data-binary @-
render.tsTypeScript
import { Formfeed } from '@formfeed/sdk';
import data from './data.json' with { type: 'json' };

const formfeed = new Formfeed({ apiKey: process.env.FORMFEED_API_KEY! });

const render = await formfeed.renders.create({
  template: 'gutschein',
  data,
});
console.log(render.status, render.download_url);
render.pyPython
import json
import os

from formfeed import Formfeed

formfeed = Formfeed(api_key=os.environ["FORMFEED_API_KEY"])

with open("data.json", encoding="utf-8") as file:
    data = json.load(file)

render = formfeed.renders.create(
    template="gutschein",
    data=data,
)
print(render.status, render.download_url)
render.phpPHP
<?php
require __DIR__ . '/vendor/autoload.php';

$formfeed = new Formfeed\Client(apiKey: getenv('FORMFEED_API_KEY'));

$render = $formfeed->renders->create([
    'template' => 'gutschein',
    'data' => json_decode(file_get_contents('data.json'), true),
]);
echo $render->status, ' ', $render->downloadUrl, PHP_EOL;
main.goGo
package main

import (
	"context"
	"encoding/json"
	"fmt"
	"log"
	"os"

	formfeed "github.com/formfeed-dev/formfeed-go"
)

func main() {
	client := formfeed.NewClient(os.Getenv("FORMFEED_API_KEY"))

	contents, err := os.ReadFile("data.json")
	if err != nil {
		log.Fatal(err)
	}
	var data map[string]any
	if err := json.Unmarshal(contents, &data); err != nil {
		log.Fatal(err)
	}

	render, err := client.Renders.Create(context.Background(), formfeed.RenderRequest{
		Template: "gutschein",
		Data:     data,
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(render.Status, render.DownloadURL)
}
Program.csC#
using System.Text.Json;
using Formfeed;

using var formfeed = new FormfeedClient(Environment.GetEnvironmentVariable("FORMFEED_API_KEY"));

var render = await formfeed.Renders.CreateAsync(new RenderRequest
{
    Template = "gutschein",
    Data = JsonSerializer.Deserialize<Dictionary<string, object?>>(File.ReadAllText("data.json")),
});
Console.WriteLine($"{render.Status} {render.DownloadUrl}");
Render.javaJava
import com.fasterxml.jackson.databind.ObjectMapper;
import dev.formfeed.Formfeed;
import dev.formfeed.RenderRequest;
import java.io.File;

public class Render {
  public static void main(String[] args) throws Exception {
    var formfeed = Formfeed.builder().apiKey(System.getenv("FORMFEED_API_KEY")).build();
    var data = new ObjectMapper().readTree(new File("data.json"));

    var request = RenderRequest.template("gutschein")
        .data(data);
    var render = formfeed.renders().create(request);
    System.out.println(render.getStatus() + " " + render.getDownloadUrl());
  }
}
render.rbRuby
require "json"
require "formfeed"

formfeed = Formfeed::Client.new(api_key: ENV.fetch("FORMFEED_API_KEY"))

render = formfeed.renders.create(
  template: "gutschein",
  data: JSON.parse(File.read("data.json"))
)
puts "#{render.status} #{render.download_url}"

Start rendering today

The free plan includes 100 units a month and free test renders. Change plans when you need more.