Skip to content

Instantly share code, notes, and snippets.

View WisaniShilumani's full-sized avatar
☄️
A quasar shining through the endless night

Wisani Shilumani WisaniShilumani

☄️
A quasar shining through the endless night
View GitHub Profile
@itsdonnix
itsdonnix / pdf.js
Last active November 26, 2023 11:50
Generate PDF on NodeJS with Puppeteer & EJS
const ejs = require('ejs')
const puppeteer = require('puppeteer')
const fs = require('fs')
const { Buffer } = require('buffer')
const { PDFDocument } = require('pdf-lib')
async function createPDF({ template, data, output, title = 'Laporan', format = 'A4' }) {
const content = ejs.render(fs.readFileSync(template).toString(), data)
const browser = await puppeteer.launch({