1from apify_client import ApifyClient
2
3
4
5client = ApifyClient("<YOUR_API_TOKEN>")
6
7
8run_input = {
9 "html": "<!doctype html><html><head><title>Example PDF</title></head><body><h1>Hello from Apify</h1><p>This HTML will be rendered as a PDF.</p></body></html>",
10 "url": "https://example.com",
11 "fileName": "output.pdf",
12 "format": "A4",
13 "printBackground": True,
14 "landscape": False,
15 "scale": 1,
16 "margin": {
17 "top": "0.4in",
18 "right": "0.4in",
19 "bottom": "0.4in",
20 "left": "0.4in",
21 },
22 "viewportWidth": 1280,
23 "viewportHeight": 720,
24 "waitForMillis": 0,
25}
26
27
28run = client.actor("rainminer/html-to-pdf-converter").call(run_input=run_input)
29
30
31print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
32for item in client.dataset(run.default_dataset_id).iterate_items():
33 print(item)
34
35