1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "urls": [
10 "https://example.com",
11 "https://en.wikipedia.org/wiki/PDF",
12 ],
13 "htmlItems": [{
14 "name": "invoice-1001",
15 "html": """<!doctype html>
16<html><head><meta charset=\"utf-8\"><title>Invoice INV-1001</title>
17<style>
18 body { font-family: Helvetica, Arial, sans-serif; color: #222; margin: 0; }
19 .top { display: flex; justify-content: space-between; align-items: flex-start; }
20 h1 { color: #1a56db; margin: 0 0 4px; }
21 .muted { color: #666; font-size: 13px; }
22 table { width: 100%; border-collapse: collapse; margin-top: 28px; }
23 th { background: #1a56db; color: #fff; text-align: left; padding: 8px; }
24 td { padding: 8px; border-bottom: 1px solid #ddd; }
25 td.n, th.n { text-align: right; }
26 .total { font-size: 18px; font-weight: bold; text-align: right; margin-top: 18px; }
27</style></head>
28<body>
29 <div class=\"top\">
30 <div><h1>INVOICE</h1><div class=\"muted\">INV-1001 · 2026-10-11</div></div>
31 <div class=\"muted\" style=\"text-align:right\">Acme Studio Ltd.<br>12 Example Street<br>London, UK</div>
32 </div>
33 <p><b>Bill to:</b> Jane Doe, Example Corp</p>
34 <table>
35 <tr><th>Item</th><th class=\"n\">Qty</th><th class=\"n\">Price</th><th class=\"n\">Amount</th></tr>
36 <tr><td>Website design</td><td class=\"n\">1</td><td class=\"n\">$1,200.00</td><td class=\"n\">$1,200.00</td></tr>
37 <tr><td>Hosting (12 months)</td><td class=\"n\">12</td><td class=\"n\">$15.00</td><td class=\"n\">$180.00</td></tr>
38 <tr><td>Support hours</td><td class=\"n\">5</td><td class=\"n\">$60.00</td><td class=\"n\">$300.00</td></tr>
39 </table>
40 <div class=\"total\">Total due: $1,680.00</div>
41 <p class=\"muted\">Payment within 14 days. Thank you for your business!</p>
42</body></html>""",
43 }],
44 "pageFormat": "A4",
45 "margins": {
46 "top": "10mm",
47 "right": "10mm",
48 "bottom": "10mm",
49 "left": "10mm",
50 },
51 "footerTemplate": "<div style=\"font-size:9px;width:100%;text-align:center;color:#666;\">Page <span class=\"pageNumber\"></span> of <span class=\"totalPages\"></span></div>",
52 "fileNameTemplate": "{index}-{name}",
53}
54
55
56run = client.actor("gazidev/html-to-pdf").call(run_input=run_input)
57
58
59print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
60for item in client.dataset(run.default_dataset_id).iterate_items():
61 print(item)
62
63