UNPKG

pdfile

Version:

PDFile is a Node.js library for generating high-quality, dynamic PDFs using Handlebars templates and Puppeteer. It supports multi-page PDFs and offers full customization. Perfect for web developers, it enables easy creation of multi-page PDFs by simply de

25 lines (22 loc) 526 B
import { LaunchOptions, Browser, launch } from 'puppeteer'; let browser: Browser | null; export const createBrowser = async (puppeteerOptions?: LaunchOptions) => { if (!browser) { browser = await launch({ headless: true, args: [ '--no-sandbox', '--disable-setuid-sandbox', '--disable-dev-shm-usage', ], ...puppeteerOptions, }); } return browser; }; export const closeBrowser = async () => { if (browser) { await browser.close(); browser = null; } };