Getting a PDF onto a Kindle, page for page
A Kindle will take an EPUB and turn it into a book. It will not take a PDF. Amazon's Kindle Previewer converts an EPUB into a Kindle book, but the step before that — turning a PDF into a fixed-layout EPUB — is left to you, and doing it well is fiddly. Every page has to stay intact, keep the right orientation, avoid being stretched or split, and carry the metadata Kindle's fixed-layout support relies on.
Leafbind exists to fill that one gap. It makes the fixed-layout EPUB; Kindle Previewer or Send to Kindle takes it the rest of the way.
Why every page is a picture
Reflowing the text is the usual way to fit a PDF onto a small screen. It breaks on scanned books, slide decks, tables, and anything set in a right-to-left script with complex ligatures — exactly the material where the original typesetting is the point. So Leafbind renders each page as an image and keeps it exactly as it was.
One canvas for the whole book
Kindle uses a single canvas per book. When pages declare different aspect ratios, the ones that don't match get distorted to fit. Leafbind places every page on one shared canvas, so nothing stretches.
Greyscale that keeps its contrast
E-ink Kindles show about sixteen levels of grey, so colour only adds weight. The conversion uses Rec. 709 luma on the gamma-encoded values, which preserves perceived lightness. Converting in linear light instead drags the mid-tones darker, and on a low-contrast panel that costs legibility.
One file, nothing to install
It is a single static binary: no poppler, no ImageMagick, no Java, no zip tool. Even the JPEG encoder is its own. Go's standard encoder always uses the example Huffman tables from the JPEG specification; Leafbind builds optimal tables for each page instead, the same procedure libjpeg uses with optimize_coding. It is lossless — the tests check the decoded pixels are identical — and jpegtran -optimize finds nothing further to remove.