Skip to content

Commit 6ee0297

Browse files
1.07
2 parents 1e36434 + d6b76f0 commit 6ee0297

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
TypeScript client for the Puppet Master HTML-to-PDF server.
44

5+
Puppet Master server: [Codebucket-Solutions/puppet-master](https://github.com/Codebucket-Solutions/puppet-master)
6+
57
The uploaded server code shows that this client talks to a single `POST /pdf` endpoint, sends a JSON body shaped like `{ task: ... }`, and downloads the generated PDF as a file stream.
68

79
## Install
@@ -41,6 +43,30 @@ await client.pdf({
4143
});
4244
```
4345

46+
## CommonJS Usage
47+
48+
```js
49+
const { PuppetMaster } = require("@codebucket/puppet-master");
50+
51+
const puppetMaster = new PuppetMaster({
52+
baseUrl: process.env.PUPPETMASTER_BASEURL,
53+
apiKey: process.env.PUPPETMASTER_APIKEY,
54+
});
55+
56+
await puppetMaster.pdf({
57+
content: allPages,
58+
launchOptions: {
59+
args: ["--no-sandbox"],
60+
},
61+
pageOptions: { waitUntil: "networkidle0" },
62+
pdfOptions: {
63+
format: "A4",
64+
printBackground: true,
65+
},
66+
pdfPath: "path to your pdf",
67+
});
68+
```
69+
4470
## Public API
4571

4672
```ts

0 commit comments

Comments
 (0)