PDF Generation
In this chapter, we will learn how to generate PDF from the resume.
Setup Puppeteer
Create a script for PDF generation:
// scripts/generate-pdf.ts
async function generatePDF() {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('http://localhost:5173', {
waitUntil: 'networkidle0',
});
await page.pdf({
path: 'resume.pdf',
format: 'A4',
printBackground: true,
});
await browser.close();
}
generatePDF();Run the Script
First, start the development server:
npm run devThen in another terminal, run the PDF generation:
npm run pdfConfiguration Options
You can customize the PDF output:
await page.pdf({
path: 'resume.pdf',
format: 'A4',
margin: {
top: '20mm',
right: '20mm',
bottom: '20mm',
left: '20mm',
},
printBackground: true,
});Next Steps
In the next chapter, we will learn about custom styles.