1import { ApifyClient } from 'apify-client';
2
3
4
5const client = new ApifyClient({
6 token: '<YOUR_API_TOKEN>',
7});
8
9
10const input = {
11 "html": `<h1 style="font-family: sans-serif; color: #2563eb;">Hello, PDF!</h1>
12<p style="font-size: 16px;">This PDF was generated by the <strong>HTML to PDF Converter</strong> actor on Apify.</p>
13<ul>
14 <li>✅ Custom paper size & margins</li>
15 <li>✅ Headers & footers with page numbers</li>
16 <li>✅ Background colors & images</li>
17</ul>`,
18 "filename": "document",
19 "format": "A4",
20 "orientation": "portrait",
21 "marginTop": "15mm",
22 "marginRight": "15mm",
23 "marginBottom": "15mm",
24 "marginLeft": "15mm",
25 "printBackground": true,
26 "scale": 1,
27 "displayHeaderFooter": false,
28 "emulateMedia": "print",
29 "waitUntil": "load",
30 "timeout": 30000
31};
32
33
34const run = await client.actor("igview-owner/html-to-pdf-api").call(input);
35
36
37console.log('Results from dataset');
38console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
39const { items } = await client.dataset(run.defaultDatasetId).listItems();
40items.forEach((item) => {
41 console.dir(item);
42});
43
44