1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "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>",
12 "url": "https://example.com",
13 "fileName": "output.pdf",
14 "format": "A4",
15 "printBackground": true,
16 "landscape": false,
17 "margin": {
18 "top": "0.4in",
19 "right": "0.4in",
20 "bottom": "0.4in",
21 "left": "0.4in"
22 },
23 "viewportWidth": 1280,
24 "viewportHeight": 720,
25 "waitForMillis": 0
26};
27
28
29const run = await client.actor("rainminer/html-to-pdf-converter").call(input);
30
31
32console.log('Results from dataset');
33console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
34const { items } = await client.dataset(run.defaultDatasetId).listItems();
35items.forEach((item) => {
36 console.dir(item);
37});
38
39