rtftableofcontents

Add table of contents to RTF document


I am trying to generate a RTF document by hand and eventually will do it programtically. I plan to improve pyRTF so that it can generate "Table of contents", which I think it can't.

I am not able to use RTF controls words (\tc, \tcf and \tcl.) to generate a TOC. http://msdn.microsoft.com/en-us/library/aa140283(office.10).aspx gives details about TOC but I couldn't find or make any example RTF which have a TOC.

So is there a simple sample showing a RTF with TOC?


Solution

  • I am creating a Table with hyperlinks to bookmarks to title on various pages.

    e.g.

    '{\\field{\\*\\fldinst  HYPERLINK \\\\l "%s"} {\\fldrslt %s}}'%(bookmark, text)
    "{\\field{\\*\\fldinst  PAGEREF %s }}"%bookmark