Skip to content

Instantly share code, notes, and snippets.

@sartimo
Created August 4, 2024 09:32
Show Gist options
  • Save sartimo/e206d2fadf6461f4491bed83b3027008 to your computer and use it in GitHub Desktop.
Save sartimo/e206d2fadf6461f4491bed83b3027008 to your computer and use it in GitHub Desktop.
Generate CV from PDFkit using BunJS
const PDFDocument = require('pdfkit');
const fs = require('fs');
// Create a document
const doc = new PDFDocument();
// Pipe the document to a file
doc.pipe(fs.createWriteStream('output.pdf'));
// Add some content
doc
.fontSize(25)
.text('My Curriculum Vitae', { align: 'center' })
.moveDown()
.fontSize(16)
.text('Name: John Doe')
.text('Email: john.doe@example.com')
.moveDown()
.text('Experience:')
.fontSize(12)
.text('Software Developer at Company XYZ')
.moveDown()
.text('Education:')
.text('B.Sc. in Computer Science')
.moveDown()
.text('Skills:')
.text('- JavaScript')
.text('- Node.js')
.text('- PDF Generation')
.moveDown()
.text('References available upon request.');
// Finalize the PDF and end the stream
doc.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment