Install pdftk
Dump the metadata of the pdf file:
pdftk [pdf_to_update] dump_data_utf8 > meta.txt
If the book already contains some bookmarks, it will look something like
...
BookmarkBegin
BookmarkTitle: 11. Diffuse Optical Tomography
BookmarkLevel: 1
BookmarkPageNumber: 262
BookmarkBegin
BookmarkTitle: 11.1. Introduction
BookmarkLevel: 2
BookmarkPageNumber: 262
BookmarkBegin
BookmarkTitle: 11.2. Modes of Diffuse Optical Tomography
BookmarkLevel: 2
BookmarkPageNumber: 262
...
Scrape the TOC for the file from some official source and convert into the format above with a custom script. Add this back into the meta.txt
file.
Finally, dump the metadata back into the PDF.
pdftk [pdf_to_update] update_info_utf8 meta.txt output [updated_pdf]