1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "template": """<!doctype html>
10<html>
11<head>
12<meta charset=\"utf-8\">
13<title>Invoice {{number}}</title>
14<style>
15 body { font-size: 11pt; color: #102a43; }
16 .top { display: flex; justify-content: space-between; align-items: flex-start; }
17 h1 { margin: 0; font-size: 22pt; }
18 .ar { font-family: 'Noto Sans Arabic', sans-serif; direction: rtl; }
19 table { width: 100%; border-collapse: collapse; margin-top: 18px; }
20 th, td { border-bottom: 1px solid #d9e2ec; padding: 8px; text-align: start; }
21 th { background: #f0f4f8; }
22 .num { text-align: end; }
23 .total td { font-weight: bold; border-top: 2px solid #102a43; }
24</style>
25</head>
26<body>
27 <div class=\"top\">
28 <div>
29 <h1>Invoice</h1>
30 <div>No. {{number}}</div>
31 <div>Date: {{formatDate date style=\"long\"}}</div>
32 </div>
33 <div class=\"ar\">
34 <h1>فاتورة</h1>
35 <div>رقم {{number}}</div>
36 <div>التاريخ: {{formatDate date style=\"long\" locale=\"ar-SA-u-ca-gregory\"}}</div>
37 </div>
38 </div>
39 <p><strong>Bill to:</strong> {{customer}}</p>
40 <table>
41 <thead><tr><th>Item</th><th class=\"num\">Qty</th><th class=\"num\">Unit price</th><th class=\"num\">Amount</th></tr></thead>
42 <tbody>
43 {{#each items}}
44 <tr><td>{{name}}</td><td class=\"num\">{{qty}}</td><td class=\"num\">{{formatCurrency price ../currency}}</td><td class=\"num\">{{formatCurrency (multiply qty price) ../currency}}</td></tr>
45 {{/each}}
46 <tr class=\"total\"><td colspan=\"3\">Total / الإجمالي</td><td class=\"num\">{{formatCurrency (sum items \"qty\" \"price\") currency}}</td></tr>
47 </tbody>
48 </table>
49</body>
50</html>""",
51 "data": [
52 {
53 "number": "INV-1001",
54 "date": "2026-10-01",
55 "customer": "Example Trading LLC",
56 "currency": "USD",
57 "items": [
58 {
59 "name": "Design work",
60 "qty": 10,
61 "price": 45,
62 },
63 {
64 "name": "Hosting, 12 months",
65 "qty": 1,
66 "price": 120,
67 },
68 ],
69 },
70 {
71 "number": "INV-1002",
72 "date": "2026-10-08",
73 "customer": "Sample Studio",
74 "currency": "EUR",
75 "items": [
76 {
77 "name": "Consulting hours",
78 "qty": 6,
79 "price": 80,
80 },
81 {
82 "name": "Travel",
83 "qty": 1,
84 "price": 95.5,
85 },
86 ],
87 },
88 {
89 "number": "INV-1003",
90 "date": "2026-10-15",
91 "customer": "Demo Supplies Co.",
92 "currency": "SAR",
93 "items": [
94 {
95 "name": "Printed brochures",
96 "qty": 500,
97 "price": 1.2,
98 },
99 {
100 "name": "Delivery",
101 "qty": 1,
102 "price": 60,
103 },
104 ],
105 },
106 ],
107 "fileName": "invoice-{{number}}",
108 "maxPdfs": 100,
109}
110
111
112run = client.actor("maliksaid/html-to-pdf").call(run_input=run_input)
113
114
115print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
116for item in client.dataset(run.default_dataset_id).iterate_items():
117 print(item)
118
119