Thanks for sharing your process, Bert. I've used pandoc to convert markdown to 
latex to pdf, but hadn't thought of it for making ebooks from scans. I 
typically use calibre for converting to epub.

I tend to prefer manuals that are formatted to be very close to how they were 
printed. My usual workflow is a single step: run 'ocrmypdf'. It is a simple OCR 
wrapper with some nice bells and whistles: preprocess (automatically deskew, 
remove background), run tesseract on all cores, try different compression 
algorithms, set the author and title, create a PDF sandwich, and ensure the end 
result is in the official PDF archival format.

Of course, Brian's massive PDF called for something a bit fancier.

1. Burst it into individual image files, one per page, using 'pdfimages'.

2. Run 'jbig2' to shrink each image into a black and white jb2 file and combine 
them using the jbig2topdf script. 

3. PdfArranger to insert the color images of the cover. Also added metadata and 
date.

4. ocrmypdf to get the invisible text layer.

5. qpdf to create a QDF file, editable in a text editor. Add the labels ("page 
numbers") by hand and convert back to PDF. (In the future I will probably use 
cpdf.)

6. tesseract on just the table of contents pages. Edit the text file to match 
cpdf's "bookmarks" format and apply it to the PDF to add an outline.

7. use scribeocr.com on the table of contents pages to correct all OCR errors, 
download the result as a hocr file.

8. Run my hocrtoc program on the hocr file to detect every line of text that 
ends with a page number. It generates a JSON file that, when run through cpdf, 
makes the table of contents clickable.

9. ??? Not sure what's next. Possibly checking for OCR errors. Maybe making the 
Index and cross references clickable. 

--b9





On July 20, 2026 5:53:37 AM PDT, bput <[email protected]> wrote:
>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
>> 
>

Reply via email to