1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "template": """<style>body{font-family:Helvetica,Arial,sans-serif;color:#1f2937;margin:0}h1{font-size:26px;margin:0;color:#0f2a4a}.top{display:flex;justify-content:space-between;border-bottom:3px solid #0f2a4a;padding-bottom:12px}.muted{color:#6b7280;font-size:12px}table{width:100%;border-collapse:collapse;margin-top:24px;font-size:13px}th{background:#0f2a4a;color:#fff;text-align:left;padding:8px}td{padding:8px;border-bottom:1px solid #e5e7eb}td.r,th.r{text-align:right}.tot{margin-top:16px;text-align:right;font-size:16px;font-weight:bold}</style>
10<div class=\"top\"><div><h1>Invoice {{ number }}</h1><div class=\"muted\">Issued {{ date }} - due {{ due }}</div></div><div style=\"text-align:right\"><b>{{ seller }}</b><div class=\"muted\">VAT {{ sellerVat }}</div></div></div>
11<p><b>Bill to:</b> {{ customer }}<br><span class=\"muted\">{{ customerCity }}</span></p>
12<table><tr><th>Description</th><th class=\"r\">Qty</th><th class=\"r\">Unit</th><th class=\"r\">Amount</th></tr>
13{% for l in lines %}<tr><td>{{ l.desc }}</td><td class=\"r\">{{ l.qty }}</td><td class=\"r\">{{ l.unit | money('EUR') }}</td><td class=\"r\">{{ (l.qty * l.unit) | money('EUR') }}</td></tr>{% endfor %}</table>
14<div class=\"tot\">Total excl. VAT: {{ total | money('EUR') }}</div>""",
15 "dataRows": [
16 {
17 "number": "2026-0141",
18 "date": "2026-11-02",
19 "due": "2026-12-02",
20 "seller": "Northwind Studio B.V.",
21 "sellerVat": "NL001234567B01",
22 "customer": "Lindqvist Outdoor AB",
23 "customerCity": "Gothenburg, Sweden",
24 "lines": [
25 {
26 "desc": "Product photography (half day)",
27 "qty": 1,
28 "unit": 640,
29 },
30 {
31 "desc": "Retouching, per image",
32 "qty": 24,
33 "unit": 9.5,
34 },
35 {
36 "desc": "Usage licence web, 12 months",
37 "qty": 1,
38 "unit": 180,
39 },
40 ],
41 "total": 1048,
42 },
43 {
44 "number": "2026-0142",
45 "date": "2026-11-05",
46 "due": "2026-12-05",
47 "seller": "Northwind Studio B.V.",
48 "sellerVat": "NL001234567B01",
49 "customer": "Café Moreau SARL",
50 "customerCity": "Lyon, France",
51 "lines": [
52 {
53 "desc": "Menu design, 2 pages",
54 "qty": 1,
55 "unit": 420,
56 },
57 {
58 "desc": "Print-ready PDF export",
59 "qty": 2,
60 "unit": 35,
61 },
62 ],
63 "total": 490,
64 },
65 {
66 "number": "2026-0143",
67 "date": "2026-11-09",
68 "due": "2026-12-09",
69 "seller": "Northwind Studio B.V.",
70 "sellerVat": "NL001234567B01",
71 "customer": "Brauerei Hofmann GmbH",
72 "customerCity": "Bamberg, Germany",
73 "lines": [
74 {
75 "desc": "Label design, 3 variants",
76 "qty": 3,
77 "unit": 260,
78 },
79 {
80 "desc": "Colour proof round",
81 "qty": 2,
82 "unit": 45,
83 },
84 {
85 "desc": "Rush fee",
86 "qty": 1,
87 "unit": 120,
88 },
89 ],
90 "total": 1020,
91 },
92 ],
93 "footerTemplate": "<div style='font-size:9px;width:100%;text-align:center;color:#6b7280'>Page <span class='pageNumber'></span> of <span class='totalPages'></span></div>",
94 "fileNameTemplate": "invoice-{{ number }}",
95 "mergeIntoOne": True,
96}
97
98
99run = client.actor("digivibetech/html-to-pdf").call(run_input=run_input)
100
101
102print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
103for item in client.dataset(run.default_dataset_id).iterate_items():
104 print(item)
105
106