Hello B 9 (and all), I've had good luck with `pandoc`, a conversion swiss-army-knife utility, especially if you have already performed OCR on the original document to get the text.
My workflow (on linux) is generally: 1. `tesseract` to OCR the page images 2. Concatenate all the resulting text files 3. Convert the text to markdown (usually minimal work to break into chapters, etc.) 4. `pandoc` to convert MD to PDF, epub, whatever you need. - Markdown can be converted to EPUB directly - Markdown needs to be converted to LaTeX (using pandoc), then use `pdftex` for best-quality PDF. - In both cases, Table of contents is generated for you. You do need to handle images separately but I think you've already solved that. Hopefully that will save you writing more tools. :-) Regards, Bert On Sun, 2026-07-19 at 08:05 -0700, B 9 wrote: > I figured out how to hyperlink the scanned Table of Contents. I wrote > a > program, hocrtoc.py > <https://github.com/hackerb9/m100manual/blob/main/hocrtoc.py> to > automatically convert OCR’d lines into links. (I had thought > something like > this must already exist, but I couldn’t find it and ended up needing > to > read the PDF specification.) You can download my latest version from: > > https://github.com/hackerb9/m100manual/raw/main/TRS-80_Model_100_Portable_Computer-jbig2.pdf >
