Add table of contents to RTF document

后端 未结 3 1042
清歌不尽
清歌不尽 2021-01-14 01:47

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

3条回答
  •  有刺的猬
    2021-01-14 02:36

    {\rtf1\ansi\deff0\adeflang1045
    {\fonttbl {\f0\fsserif\fcharset238 Verdana;}}
    
    \titlepage\line\line\line\line\line
    {\pard \s1\f0\b\scaps\fs80\qc
    {\field{\*\fldinst HYPERLINK \\l "toc"} {\fldrslt\ul0 Title Page\line\fs30\scaps0\b0 go to Table of Contents}}
    \par}
    
    \page{\*\bkmkstart page2}{\*\bkmkend page2}\line\line\line\line\line{\pard\f0\fs80\b\scaps\qc\sa10000{\field{\*\fldinst HYPERLINK \\l "toc"} {\fldrslt Page \chpgn}}\par}
    \page{\*\bkmkstart page3}{\*\bkmkend page3}\line\line\line\line\line{\pard\f0\fs80\b\scaps\qc\sa10000{\field{\*\fldinst HYPERLINK \\l "toc"} {\fldrslt Page \chpgn}}\par}
    \page{\*\bkmkstart page4}{\*\bkmkend page4}\line\line\line\line\line{\pard\f0\fs80\b\scaps\qc\sa10000{\field{\*\fldinst HYPERLINK \\l "toc"} {\fldrslt Page \chpgn}}\par}
    \page{\*\bkmkstart page5}{\*\bkmkend page5}\line\line\line\line\line{\pard\f0\fs80\b\scaps\qc\sa10000{\field{\*\fldinst HYPERLINK \\l "toc"} {\fldrslt Page \chpgn}}\par}
    
    \page{\*\bkmkstart toc}{\*\bkmkend toc}{\pard\sa1000\f0\fs50\b\qc{\field{\*\fldinst TOC}{\fldrslt Table of Contents}}\par}
    {\pard\f0\fs28\fi0\trowd\cellx8000\cellx8600
    \pard\intbl\ql {\field{\*\fldinst HYPERLINK \\l "page2"} {\fldrslt\ul0 Link to anchor #page2}}\cell\pard\intbl\qr {\field{\*\fldinst PAGEREF page2}}\cell\row
    \pard\intbl\ql {\field{\*\fldinst HYPERLINK \\l "page3"} {\fldrslt\ul0 Link to anchor #page3}}\cell\pard\intbl\qr {\field{\*\fldinst PAGEREF page3}}\cell\row
    \pard\intbl\ql {\field{\*\fldinst HYPERLINK \\l "page4"} {\fldrslt\ul0 Link to anchor #page4}}\cell\pard\intbl\qr {\field{\*\fldinst PAGEREF page4}}\cell\row
    \pard\intbl\ql {\field{\*\fldinst HYPERLINK \\l "page5"} {\fldrslt\ul0 Link to anchor #page5}}\cell\pard\intbl\qr {\field{\*\fldinst PAGEREF page5}}\cell\row
    \par}
    }
    

提交回复
热议问题