I've got an application that generates a fairly long FlowDocument. It uses a "custom" paginator to wrap a header and footer around each page when printed. In addition, each page contains one or more "subheadings".
I would like to have it also automatically create a table of contents for this document, showing what subheadings appeared on each page.
Here's the trouble. I don't know what subheadings appear on each page until I print the document and it passes through the paginator, which breaks the document into pages. But by that time, everything has been reduced to Visuals and seems to no longer contain any relevant information about the actual objects that I put in the document (so I can't read any Tag properties or even the content).
Does anyone have any clever ways that I could determine during/before printing what items appear on each page?