CoolFace
Apppublic

b-mozz/reflow

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
App README

Reflow

Reading PDFs on a phone is miserable. The page is taller than your screen, the text is too small to read, so you zoom in — and now you can't see a whole line, so you scroll left and right after every sentence. It's the kind of small daily annoyance you stop noticing because there's nothing you can do about it.

Reflow takes any PDF and slices each page into wide, short strips — sized like a phone held sideways. You upload the book, get a new PDF back, and read it by swiping from one strip to the next. No zooming, no scrolling, no pinching.

I made it because I read a lot of Bengali books that only exist as scanned PDFs. Apps that "reflow" text only work when the PDF has selectable text underneath, which scanned books don't. Reflow doesn't care — it works on scanned pages, born-digital pages, comics, English, Bengali, Arabic, anything. It looks at where the ink is and cuts between the lines.

It tries to be careful: every cut is nudged up or down to land in the blank space between two lines, so no sentence gets sliced in half.

That's the whole thing. Free, runs in your browser via Hugging Face Spaces, no signup, your PDF never gets stored.


How it's built

LibraryWhat it does here
pypdfReads the input PDF and writes the output one. The "cropping" is really just copying each page and telling the PDF reader, "only show this strip of it."
PyMuPDF (fitz)Renders each page to a low-resolution image so we can scan it pixel by pixel and find rows with no text — those are the safe places to make a cut.
FastAPI + UvicornThe little Python web server that accepts your upload and sends back the converted PDF.
Plain HTML / CSS / JSThe upload page. No framework, no build step.
DockerPackages everything into one image so it runs the same on a laptop, a server, or Hugging Face Spaces.

Running it yourself

bash
python3 -m pip install -r requirements.txt
python3 -m uvicorn app:app --reload

Then open <http://127.0.0.1:8000>.

There's also a command-line version if you'd rather skip the browser:

bash
python3 cropper.py input.pdf output.pdf -n 3

(-n 3 means "3 strips per page" — pick whatever number reads best on your phone.)