/// <summary> /// Mark up the paragraph and style of indd file with special xml tags. /// </summary> private void MarkupInddParagraph(InDesign.XMLElement p_parentElm, InDesign.Paragraph p_paragraph) { InDesign.XMLElement xmlElement = null; InDesign.Font font = null; // Add a new xml element which will be used to mark up a paragraph. InDesign.XMLElements subElements = p_parentElm.XMLElements; xmlElement = subElements.Add(INDD_PARAGRAPH_TAG, INDD_XMLCONTENT); // Get the paragraph's attributes to be translated. // For example // FontFamily: Times New Roman // PointSize: 12 font = (InDesign.Font)p_paragraph.AppliedFont; xmlElement.XMLAttributes.Add(FONT_FAMILY_ATTRIBUTE, font.FontFamily); xmlElement.XMLAttributes.Add(FONT_STYLE_ATTRIBUTE, p_paragraph.FontStyle); xmlElement.XMLAttributes.Add(FONT_SIZE_ATTRIBUTE, p_paragraph.PointSize.ToString()); // Markup the paragraph with xml element // so that it can be exported into xml file. p_paragraph.Markup(xmlElement); }
/// <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); } } }