I want to insert a horizontal line into .doc-file with fitting by width of text line. Does Aspose.Words provide build-in methods for that? Sorry, my English is not very well.
Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Thanks for your request.
1. You can insert Line shape into your document. Please see the following code:
//Open or create document and create DocumentBuilder
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
//Get page width
double width = builder.CurrentSection.PageSetup.PageWidth;
//Create Line shape
Shape line = new Shape(doc, ShapeType.Line);
//set line width
line.Width = width;
//Set vertical and horizontal position.
line.RelativeHorizontalPosition = RelativeHorizontalPosition.Page;
line.HorizontalAlignment = Aspose.Words.Drawing.HorizontalAlignment.Center;
line.RelativeVerticalPosition = RelativeVerticalPosition.Paragraph;
//set line color, style etc
line.StrokeColor = Color.Red;
line.Stroke.LineStyle = ShapeLineStyle.Triple;
line.StrokeWeight = 5;
//Insert line into the document
builder.InsertNode(line);
//Save output document
doc.Save(@"Test019\out.doc");
2. You can set paragraph top or bottom border as shown in the following code:
//Open or create document and create DocumentBuilder
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
//Get bottom border
Border bottomBorder = builder.CurrentParagraph.ParagraphFormat.Borders[BorderType.Bottom];
//Set color, style etc
bottomBorder.LineStyle = LineStyle.Single;
bottomBorder.LineWidth = 5;
bottomBorder.Color = Color.YellowGreen;
//Save output document
doc.Save(@"Test019\out.doc");
Hope this helps.
Best regards.
Thank you, Alexey!