Sounds like it would be sanest for you to insert a blank page where the TOC would be, build your file while keeping track of pertinent info, then go back and open that blank page and put your TOC in.
Another solution would be to build each piece separately. So, you build your file and keep track of info. Then, you build your TOC as a completely separate PDF. There are dozens of ways of concatenating PDFs together, many of which use ghostscript (gs). YMMV
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?