Pdf.tocgen uses embedded font attributes and positions to generate ToCs for PDFs and works with software-generated PDFs, not scanned ones. It's open-source, Python 3 compatible, and its workflow involves the commands pdfxmeta, pdftocgen, and pdftocio.