PodPDF is a lightweight, open-source utility powered by Bun to convert Markdown files into professional PDFs. Unlike paid SaaS solutions, PodPDF runs locally on your machine, ensuring zero cost, total privacy, and lightning-fast performance.
This guide provides a checklist of steps to build and use the PodPDF script locally.
Get your environment ready for PodPDF.
mkdir podpdf && cd podpdfbun init -ybun add puppeteer (Headless browser for PDF generation)bun add markdown-it (Markdown parser)bun add -d @types/markdown-it (Types for TypeScript)Create the podpdf.ts script to handle the conversion.
podpdf.ts)puppeteer and markdown-it.process.argv.printToPDF.import puppeteer from "puppeteer";
import MarkdownIt from "markdown-it";
const md = new MarkdownIt();
const inputFile = process.argv[2];
const outputFile = process.argv[3] || "output.pdf";
if (!inputFile) {
console.error("Usage: bun podpdf.ts <input.md> [output.pdf]");
process.exit(1);
}
try {
// 1. Read Markdown
const markdown = await Bun.file(inputFile).text();
// 2. Convert to HTML with basic styling
const html = `
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: 'Helvetica', sans-serif; padding: 40px; line-height: 1.6; }
h1 { border-bottom: 2px solid #333; padding-bottom: 10px; }
table { width: 100%; border-collapse: collapse; margin: 20px 0; }
th, td { border: 1px solid #ddd; padding: 12px; text-align: left; }
th { background-color: #f4f4f4; }
code { background: #f4f4f4; padding: 2px 5px; border-radius: 4px; }
</style>
</head>
<body>
${md.render(markdown)}
</body>
</html>
`;
// 3. Generate PDF
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setContent(html, { waitUntil: "networkidle0" });
await page.pdf({ path: outputFile, format: "A4", printBackground: true });
await browser.close();
console.log(`✅ PDF created: ${outputFile}`);
} catch (error) {
console.error("Error generating PDF:", error);
}
Once your script is ready, follow this flow to generate a PDF.
invoice.md).bun podpdf.ts invoice.md invoice.pdfCreate a file named invoice.md with the following content to test your setup.
# Invoice #001
**From:** My Company Inc.
**To:** Jane Doe
| Item | Qty | Price |
| :--- | :-- | :---- |
| Consulting | 10 | $1500 |
| Setup Fee | 1 | $200 |
**Total: $1700**
Run:
bun podpdf.ts invoice.md invoice.pdf
By following this guide, you have a completely free, open-source, and customizable PDF generator using the power of Bun.