23 lines
615 B
JavaScript
23 lines
615 B
JavaScript
import puppeteer from "puppeteer";
|
|
import { dungeonTemplate } from "./dungeonTemplate.js";
|
|
|
|
export async function generateDungeonPDF(data, outputPath = "dungeon.pdf") {
|
|
const browser = await puppeteer.launch({
|
|
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
|
});
|
|
const page = await browser.newPage();
|
|
|
|
const html = dungeonTemplate(data);
|
|
await page.setContent(html, { waitUntil: "networkidle0" });
|
|
|
|
await page.pdf({
|
|
path: outputPath,
|
|
format: "A4",
|
|
landscape: true,
|
|
printBackground: true,
|
|
});
|
|
|
|
await browser.close();
|
|
console.log(`Dungeon PDF saved to ${outputPath}`);
|
|
}
|