using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Docs.Word; namespace Paragraph_Styles { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { // Creates a new instance of Document class and reads a .doc file into this structure Document Doc = new Document(); Doc.ReadDoc(@"..\..\Data\WordParagraph.doc"); // Writes the type of node TextBox.Text += "Type of node : " + (NodeType)Doc.Sections[0].Nodes[0].Type + "\r\n"; // If this node is a paragraph... if (Doc.Sections[0].Nodes[0].Type == NodeType.Paragraph) { // Gets the paragraph properties ParagraphStyle tStyle = ((Paragraph)Doc.Sections[0].Nodes[0]).Style; // Writes them TextBox.Text += "Paragraph is in list : " + tStyle.List.isInList + "\r\n"; TextBox.Text += "Alignment : " + tStyle.Alignment + "\r\n"; TextBox.Text += "Keep paragraph on single page : " + tStyle.KeepOnSinglePage + "\r\n"; TextBox.Text += "Next paragraph on the same page : " + tStyle.KeepFollowingParOnSamePage + "\r\n"; TextBox.Text += "Page break before paragraph : " + tStyle.PageBreakBefore + "\r\n"; TextBox.Text += "Don't counting the lines : " + tStyle.NoLineNumbers + "\r\n"; TextBox.Text += "Right indent in twips : " + tStyle.RightIndent + "\r\n"; TextBox.Text += "Left indent in twips : " + tStyle.LeftIndent + "\r\n"; TextBox.Text += "Indent of the first line of paragraph : " + tStyle.FirstLineIndent + "\r\n"; if (tStyle.LineSpacing.Multiply == true) TextBox.Text += "Line-spacing : " + (float)tStyle.LineSpacing.Spacing/240 + "x \r\n"; else TextBox.Text += "Line-spacing : " + tStyle.LineSpacing.Spacing + "twips \r\n"; TextBox.Text += "Spacing before paragraph in twips : " + tStyle.SpacingBefore + "\r\n"; TextBox.Text += "Spacing after paragraph in twips : " + tStyle.SpacingAfter + "\r\n"; TextBox.Text += "If this paragraph has custom tab stops : " + tStyle.HasCustomTabStops + "\r\n"; TextBox.Text += "If this paragraph has borders : " + tStyle.Borders.HasBorders + "\r\n"; TextBox.Text += "Auto-hyphenation : " + tStyle.AutoHyphenation + "\r\n"; TextBox.Text += "If this paragraph has shading : " + tStyle.Shading.HasShading + "\r\n"; TextBox.Text += "Outline level : " + tStyle.OutlineLevel + "\r\n"; } } } }