ShapeBaseIsHorizontalRule Property |
Namespace: Aspose.Words.Drawing
// Use a document builder to insert a horizontal rule DocumentBuilder builder = new DocumentBuilder(); Shape shape = builder.InsertHorizontalRule(); HorizontalRuleFormat horizontalRuleFormat = shape.HorizontalRuleFormat; horizontalRuleFormat.Alignment = HorizontalRuleAlignment.Center; horizontalRuleFormat.WidthPercent = 70; horizontalRuleFormat.Height = 3; horizontalRuleFormat.Color = Color.Blue; horizontalRuleFormat.NoShade = true; MemoryStream stream = new MemoryStream(); builder.Document.Save(stream, SaveFormat.Docx); // Get the rule from the document's shape collection and verify it Shape horizontalRule = (Shape)builder.Document.GetChild(NodeType.Shape, 0, true); Assert.True(horizontalRule.IsHorizontalRule); Assert.True(horizontalRule.HorizontalRuleFormat.NoShade); Assert.AreEqual(HorizontalRuleAlignment.Center, horizontalRule.HorizontalRuleFormat.Alignment); Assert.AreEqual(70, horizontalRule.HorizontalRuleFormat.WidthPercent); Assert.AreEqual(3, horizontalRule.HorizontalRuleFormat.Height); Assert.AreEqual(Color.Blue.ToArgb(), horizontalRule.HorizontalRuleFormat.Color.ToArgb());