Can I edit/create a PDF's Table of Contents with freeware?
I found PDFtk Server and Coherent PDF Command Line Tools have a wide range of PDF command line utilities.

I've used both tools on and off, but never needed to do any TOC work. The Bookmarks section in Coherent's Usage Examples Page looks like it may be an approach to experiment with:

6. Bookmarks

cpdf -list-bookmarks in.pdf

List the bookmarks in in.pdf. This would produce:

0 "Part 1" 1 open
1 "Part 1A" 2
2 "Part 1B" 3
0 "Part 2" 4
1 "Part 2a" 5


cpdf -add-bookmarks bookmarks.txt in.pdf -o out.pdf

Add bookmarks in the same form from a prepared file bookmarks.txt to in.pdf, writing to out.pdf.