0

A RTF document is edited on the server based off of user inputs on the web page. When the user hits the download button, it creates a word document with some of the sections deleted out of the RTF document.

Now that sections have been deleted, the ToC is incorrect. How do I update the ToC automatically when the word doc is opened ?

Macro doesn't seem to update the ToC automatically.

Php edits the rtf document using str_replace() and file_put_contents() Then it downloads it to the user on a website as a doc file

Just want the ToC to update automatically when the user opens the doc, so it doesn't have to be done manually.

munsifali
  • 1,732
  • 2
  • 24
  • 43
Dash
  • 1
  • 2
  • 1
    Could you give us more information about this macro you mention, please? You can use the [edit] link below the question to add the information. What technology is used to create the Word document from the RTF? – Cindy Meister Jan 22 '19 at 06:22
  • Ideally it would be a macro that automatically creates or updates the ToC as soon as a use opens the document. That was php can do anything to the doc and the ToC will always be correct. – ioan Jan 22 '19 at 21:27
  • We couldn't get php to edit a word document with the file and string functions, so we made an rtf template, which worked. Then when a user wants to download it, it does header("Content-Disposition: attachment; filename='".$name.".doc"); which seems to convert it to word – ioan Jan 22 '19 at 21:30
  • A real DOC would not update its ToC, if I read this correctly: https://stackoverflow.com/questions/3982624/is-it-possible-to-update-the-toc-tableofcontents-of-a-word-document-generated - so even if the RTF is converted to DOC somehow, it would not work as expected – mjn Feb 08 '19 at 18:51

0 Answers0