Hi,
I am creating a document and I would like to add a Horizontal Rule. Can you tell me how?
I can see there is a property IsHorizontal rule on Shape, but how to create a Shape of that type?
Thanks,
Lukasz
Hi,
I am creating a document and I would like to add a Horizontal Rule. Can you tell me how?
I can see there is a property IsHorizontal rule on Shape, but how to create a Shape of that type?
Thanks,
Lukasz
Thanks for your inquiry. Please ZIP and attach your expected output Word document here for our reference. We will then provide you code example according to your requirement.
Hi Tahir,
Thank you for your prompt response. Please see the example attached.
Thank you,
Lukasz
HorizontalRule.zip (10.5 KB)
Thanks for sharing the document. Please use the following code example to get the desired output. Hope this helps you.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
//Solution 1
builder.InsertParagraph();
builder.InsertHtml("<hr>");
//Solution 2
Paragraph paragraph2 = builder.InsertParagraph();
paragraph2.ParagraphFormat.Borders.Bottom.LineStyle = LineStyle.Single;
doc.Save(MyDir + "18.8.docx");
Hi Tahir,
Thank you for your response.
Regarding solution 2, I can see this is not exactly what solution 1 does. The shape rendered using builder.InsertHtml("<hr>"); is different. Can you tell me what is that Shape or how to create one not using InsertHtml?
Thanks,
Lukasz
Thanks for your inquiry. Unfortunately, Aspose.Words does not support the requested feature at the moment. However, we have logged this feature request as WORDSNET-17397 in our issue tracking system. You will be notified via this forum thread once this feature is available. We apologize for your inconvenience.
Please use the solution shared in my previous post.
Hi Tahir,
Thank you for logging this.
I am just wondering if there is any update on the ticket WORDSNET-17397?
Thank you,
Lukasz
Thanks for your inquiry. We try our best to deal with every customer request in a timely fashion, we unfortunately cannot guarantee a delivery date to every customer issue. We work on issues on a first come, first served basis. We feel this is the fairest and most appropriate way to satisfy the needs of the majority of our customers.
We will inform you via this forum thread once there is an update available on this feature.
The issues you have found earlier (filed as WORDSNET-17397) have been fixed in this Aspose.Words for .NET 18.10 update and this Aspose.Words for Java 18.10 update.
The DocumentBuilder.InsertHorizontalRule method was added into Aspose.Words API to insert a horizontal rule shape into the document.
Following code example shows how to insert horizontal rule shape in a document and customize the formatting.
// Use a document builder to insert a horizontal rule
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
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;