/// <summary>
        /// Saves one section of a document as an HTML file.
        /// Any embedded images are saved as separate files in the same folder as the HTML file.
        /// </summary>
        private static void SaveHtmlTopic(Section section, Topic topic)
        {
            Document dummyDoc = new Document();
            dummyDoc.RemoveAllChildren();
            dummyDoc.AppendChild(dummyDoc.ImportNode(section, true, ImportFormatMode.KeepSourceFormatting));

            dummyDoc.BuiltInDocumentProperties.Title = topic.Title;

            HtmlSaveOptions saveOptions = new HtmlSaveOptions();
            saveOptions.PrettyFormat = true;
            // This is to allow headings to appear to the left of main text.
            saveOptions.AllowNegativeIndent = true;
            saveOptions.ExportHeadersFootersMode = ExportHeadersFootersMode.None;

            dummyDoc.Save(topic.FileName, saveOptions);
        }
        /// <summary>
        /// Splits the current document into one topic per section and saves each topic
        /// As an HTML file. Returns a collection of Topic objects.
        /// </summary>
        private ArrayList SaveHtmlTopics()
        {
            ArrayList topics = new ArrayList();
            for (int sectionIdx = 0; sectionIdx < mDoc.Sections.Count; sectionIdx++)
            {
                Section section = mDoc.Sections[sectionIdx];

                string paraText = section.Body.FirstParagraph.GetText();

                // The text of the heading paragaph is used to generate the HTML file name.
                string fileName = MakeTopicFileName(paraText);
                if (fileName == "")
                    fileName = "UNTITLED SECTION " + sectionIdx;

                fileName = Path.Combine(mDstDir, fileName + ".html");

                // The text of the heading paragraph is also used to generate the title for the TOC.
                string title = MakeTopicTitle(paraText);
                if (title == "")
                    title = "UNTITLED SECTION " + sectionIdx;

                Topic topic = new Topic(title, fileName);
                topics.Add(topic);

                SaveHtmlTopic(section, topic);
            }

            return topics;
        }