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 "scale": 1,
18 "margin": {
19 "top": "0.4in",
20 "right": "0.4in",
21 "bottom": "0.4in",
22 "left": "0.4in"
23 },
24 "viewportWidth": 1280,
25 "viewportHeight": 720,
26 "waitForMillis": 0
27};
28
29
30const run = await client.actor("rainminer/html-to-pdf-converter").call(input);
31
32
33console.log('Results from dataset');
34console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
35const { items } = await client.dataset(run.defaultDatasetId).listItems();
36items.forEach((item) => {
37 console.dir(item);
38});
39
40