All projects
Available

Lease PDF

A no-signup sublease generator: fill in a short form, and a Typst compiler running in your browser typesets a ready-to-sign PDF without uploading anything.

The Lease PDF review screen showing a completed, ready-to-sign fictional sublease

A short structured form becomes a reviewed, ready-to-sign sublease. Every name and address in this image is fictional.

From a LaTeX file to a form

I had a residential sublease written in LaTeX. It compiled with Tectonic into a clean, signable PDF, as long as you had a TeX setup and ran it from the command line. Lease PDF puts that document behind a form: fill in the parties, the address, the dates, and the rent, click Generate, review the result, and download the PDF. It all runs in your browser, so the names, addresses, and rent never leave your device.

The first page of a fictional sublease generated by Lease PDF

The first page of the fictional two-page sample PDF.

A 27 MiB compiler for a two-page lease

The brief I started from said: "A simple form-fill app that ships a 30 MB WebAssembly TeX engine is a smell." Then I shipped a 27 MiB WebAssembly Typst compiler. The pure-JavaScript PDF libraries are a few hundred kB gzipped, but with the lower-level ones you end up doing the layout by hand. For one lease, one of those might have been enough. For something that should also take my résumé template, Typst was worth the weight: real typesetting, a compiler that runs in the browser, and JSON input, so your text goes into the document as data and never gets pasted into template source.

Cloudflare serves static files up to 25 MiB, and the compiler is 27.01 MiB. So the build gzips it to 10.24 MiB, and a Web Worker inflates it with the browser's own DecompressionStream. It checks the first bytes before inflating it, because some servers helpfully un-gzip the file on the way out.

The compiler also calls new Function() while it boots, which a strict content security policy blocks. I didn't want unsafe-eval on the page that holds your name and address. A dedicated worker takes its policy from its own script response, so the compiler runs from /typst-worker/, and only that path gets unsafe-eval. Cloudflare's _headers file made this harder than it sounds, because it stacks matching rules: a policy on /* would also land on the worker, the browser would enforce both, and eval would be blocked again. So the policy is set per path and never on /*. Both the page and the worker can only connect to their own origin, and the fonts ship with the app, with the compiler's CDN font download switched off.

Warming up the compiler

The page starts downloading the compiler as soon as it opens, with a progress bar that tracks the actual bytes. Then it compiles a throwaway lease full of placeholder data, because the compiler's first run is slow: about 650 ms in testing. When I timed it by hand, the whole preload took 2.8 seconds in WebKit. After that, the first real render took 69 ms in Chromium and 88 ms in WebKit, and later renders took 8 ms and 3 ms in the same two browsers. That's too fast to read as anything having happened, so the Generate button holds its loader for at least 1.1 seconds, long enough for the little typesetting animation to finish.

What it doesn't do yet

It makes one document, the sublease. The résumé template isn't ported yet. Signing happens after you download: print it, or use a PDF app's signature tool.

Try it at leasepdf.com.