/// <summary> /// Create XML tags in the indd file, /// and mark up the text and style of indd file with special xml tags. /// </summary> private void MarkupInddFile() { // Get root element of the document. InDesign.XMLElements elements = (InDesign.XMLElements)m_inDesignDoc.XMLElements; InDesign.XMLElement rootElm = (InDesign.XMLElement)elements.FirstItem(); // Get all stories in current document. InDesign.Stories stories = m_inDesignDoc.Stories; int storyCount = stories.Count; InDesign.Story story = null; for (int i = 0; i < storyCount; i++) { if (i == 0) { story = (InDesign.Story)stories.FirstItem(); } else { story = (InDesign.Story)stories.NextItem(story); } MarkupInddStory(rootElm, story); } }
/// <summary> /// Mark up the story and style of indd file with special xml tags. /// </summary> private void MarkupInddStory(InDesign.XMLElement p_parentElm, InDesign.Story p_story) { ArrayList paraList = new ArrayList(); InDesign.Paragraph paragraph = null; InDesign.XMLElement xmlElement = null; InDesign.XMLElements subElements = null; subElements = p_parentElm.XMLElements; xmlElement = subElements.Add(INDD_STORY_TAG, INDD_XMLCONTENT); p_story.Markup(xmlElement); // Get all paragraphes. for (int i = 0; i < p_story.Paragraphs.Count; i++) { if (i == 0) { paragraph = (InDesign.Paragraph)p_story.Paragraphs.FirstItem(); } else { paragraph = (InDesign.Paragraph)p_story.Paragraphs.NextItem(paragraph); } paraList.Add(paragraph); } // Mark up each paragraph. foreach (InDesign.Paragraph eachparagraph in paraList) { if (eachparagraph.Contents.ToString().Trim().Length > 0) { MarkupInddParagraph(xmlElement, eachparagraph); } } }