# Creating a "table of content" for a doc-file in a HTML to DOC conversion

I was wondering if it is possible to create a "Table of Contents" dynamicly in the conversion process.

I've written a PHP script which puts some html together then adds the footer and header using the sdfield tag(<div title="footer"> <center><sdfield type=PAGE subtype=RANDOM format=PAGE>14</sdfield>/<sdfield type=DOCSTAT subtype=PAGE format=PAGE>14</sdfield></center> </div>) to a HTML file. Then I convert the HTML file to a DOC file (using soffice --headless --convert-to doc:"MS Word 97") because that is the result we're aiming for.

The file is nearly perfect to our requirements except for the missing "Table of contents" (preferably on page 3). However at this point i'm lost. Is there a special tag I can use here? Or is it possible to use some sort of document as a template so that i can insert the table tag beforehand?

edit retag close merge delete

Sort by » oldest newest most voted

Maybe an alternative solution would be simpler. I've created references (anchor links) and those seem to work fine, now all I need it to get the pagenumber for the item so I can show them.

more

I assume you generate then your TOC with fields. Fields may display content, section number, page number, … You just need to enter two fields: one for content, the other one for page number.

( 2017-12-19 14:42:42 +0100 )edit

You definitely need to insert some sort of tag at the location where you want your TOC. But this solves only half the problem.

Contents of the TOC is gathered from specific paragraph styles, but default Heading 1 to Heading 10. To make your TOC from <H1> to H6>, you need to customize the TOC engine. The simplest way is to define a template with paragraph styles H1 to H6 matching your taste for sections headings. In Outline & Numbering tab of style definition, give the required outline level to your Hx styles (1 for H1, 2 for H2, etc.).

Save the template.

Do the conversion, then import the styles from your template and Tools->Update->Update all.

Since this implies manual process, you can insert the TOC with Insert->Tables & Indexes->Tables & Indexes on the same occasion.

This procedure can be automated with macros but I never used any.

If this answer helped you, please accept it by clicking the check mark ✔ to the left and, karma permitting, upvote it. If this resolves your problem, close the question, that will help other people with the same question.

more

actually the TOC engine doesn't seem to have any issues with the H1~H6 tags.. since after conversion i added the TOC manually and that gave the exact result we're aiming for.

however.. the question "What tag" remains.

Your solution requires my environment to run the gui, however that's not an option for me on this server environment. Thanks for explaining your approach though!

( 2017-12-18 15:08:53 +0100 )edit