> Site index for LLMs: https://www.nandan.fyi/llms.txt

# Handwriting

> A web app that generates PDFs that look handwritten - typed text rendered in a handwritten style, with properly structured output you can still select and copy.

- Published: 2023-06-16
- Source: https://github.com/nandan-varma/handwriting
- Live: https://writing.nandanvarma.com
- Canonical: https://www.nandan.fyi/projects/handwriting

Assignments at college sometimes had to be handwritten. I kept forgetting. So I built a tool that takes typed text and generates a PDF that looks handwritten - with configurable fonts, spacing, and margins. The PDFs are properly structured too, not just image screenshots, so you can still select and copy the text.

## Features

- Converts typed text to a handwritten-style PDF
- Properly structured PDFs via pdf-lib - text is selectable and copyable
- Configurable margin, font size, and line spacing
- Minimal UI

## Neural handwriting generation

I also built a second version using TensorFlow and a recurrent neural network (Flask + Docker) that generates much more realistic handwriting by learning stroke patterns from a dataset. It works locally - the RNN learns to vary character spacing and slant in ways that look more natural than a static font mapping. Deployment is blocked by the Docker/ML model hosting cost, so the live site runs the font-based version.

## Key decisions

- **pdf-lib over canvas-to-image export** — a properly structured PDF keeps the text selectable and copyable; exporting a canvas screenshot produces an image that looks the same but throws away the semantic content
- **Configurable spacing and margins** — different page sizes and line rulings have different requirements; making these parameters rather than constants lets the output match the actual assignment format

## Built with

- [Next.js](https://nextjs.org)
- [pdf-lib](https://pdf-lib.js.org/) - PDF generation
- [tailwindcss](https://tailwindcss.com)
- Deployed on [Vercel](https://vercel.com)
