for python 3.6 support, use pdf-toc == 1.1.4 usage: pdf-toc [-h] [--version] [--show-toc {json,toc}] [-t TOC] [-d DEST] [-T {json,toc}] [-f] [-m] source pdf ToC ...
In fact, you can develop this idea to the point of getting the periodic table of elements from a quantum field theory on the Einstein universe! I worked that out here: Second quantization for the ...