How to create hierarchical bookmarks on scanned PDF files?

How can I create a tree table of content in a PDF that can be expanded and collapse like the image below?

I know we can go to a page and add a bookmark to include that page in the table of content, but I cannot create a "tree" this way. In addition, if we create a table of contents in a Word document using styles, we can have a table of content by converting the Word into PDF, but I'm talking about a PDF created from scanned book images.

enter image description here


Jpdfbookmark can work for scanned books

Watch tutorial video ≫

Step 1: Prepare the table of content

Save the TOC in a .txt file in this format:

Chapter 1. The Beginning/23
    Para 1.1 Child of The Beginning/25,FitWidth,96
        Para 1.1.1 Child of Child of The Beginning/26,FitHeight,43
Chapter 2. The Continue/30,TopLeft,120,42
    Para 2.1 Child of The Beginning/32,FitPage

You can ORC the TOC and use regex to fix it.

Step 2: Load that TOC

Step 3: Prepare for step 4

This sounds dumb, but if you miss it you will be frustrated and have to do it again. Expand all bookmarks (Ctrl + E), select all of them, then go to Tools → Apply Page Offset

Step 4: Apply page offset

This step should be self-explained. Don’t forget to save.


That’s it. You are done. For more information, you can read its its manual. The program has command line mode and can work on Linux, Mac.

If there are non-Roman characters, be sure to use the same encoding when dumping and applying bookmarks.

I also have a complete guide to process scanned books, you may want to check it out: The ultimate guide to process scanned books.


FYI:
• How to OCR tables of contents to proper outputs?
• How can I split in half a double-page scanned PDF in a single pass?