-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (26 loc) · 903 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const express = require("express");
const playwright = require("playwright");
const app = express();
const port = 3000;
app.get("/", async (req, res) => {
console.log("building pdf");
const browser = await playwright["chromium"].launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto("http://payaca.com/");
const pdf = await page.pdf({ format: "A4" });
await browser.close();
// return pdf
res.send(pdf);
});
app.listen(port, async () => {
console.log("building pdf");
const browser = await playwright["chromium"].launch();
const context = await browser.newContext();
const page = await context.newPage();
await page.goto("http://payaca.com/");
const pdf = await page.pdf({ format: "A4" });
await browser.close();
console.log("pdf built");
console.log(`Example app listening at http://localhost:${port}`);
});