← projects
TypeScript

markdown-to-pdf

markdown-to-pdf
TypeScript
OVERVIEW

A local-first markdown editor with live preview that exports to PDF, DOCX, PPTX, XLSX, and HTML. Built on CodeMirror 6 and the unified/remark/rehype pipeline with KaTeX math and syntax-highlighted code blocks, rendering PDFs via Puppeteer. No account, no database, and no AI — everything runs in the browser and on-demand server rendering only.

TECH STACK
Next.jsTypeScriptCodeMirrorPuppeteerTailwind CSS
KEY FEATURES
  • PDF export via Puppeteer with Georgia serif typography and styled code blocks, tables, and blockquotes
  • DOCX export with custom heading/list/blockquote parsing tailored for Word-native formatting
  • PPTX export that starts a new slide per H1 heading, falling back to even splits when there are none
  • XLSX export that auto-detects GFM tables and turns each one into its own worksheet
HOW IT WORKS
  1. 01You write and edit Markdown in a CodeMirror-based editor with live preview
  2. 02On export, the content and formatting options are sent to a conversion API route
  3. 03markdown-it renders the Markdown into a fully styled HTML document with fonts, headers/footers, and watermark
  4. 04puppeteer-core launches the Lambda-sized headless Chromium build to print that HTML to a PDF buffer
  5. 05DOCX, PPTX, and XLSX exports run through separate parsers tailored to each format's structure
CHALLENGES

Server-side PDF export needs a full headless Chromium instance, which is heavy to run inside a serverless function. Solved by using @sparticuz/chromium, a Lambda-sized headless-Chromium build driven by puppeteer-core, with a hard 45-second execution cap to stay inside serverless timeout limits.

METRICS
20
API routes
130
Total dependencies
8
App pages
46,343
Source LOC
GALLERY
markdown-to-pdf screenshot