Horizontal line?


#1

Is there a way to insert a horizontal line? There are several InsertXYZ methods on the DocumentBuilder, but I didn't see one I thought would work.

I just want a simple black line ( HTML:


) to be inserted at the position of my choosing. I can do it in MS Word by going to Format | Borders and Shading and click the Horizontal Line button.

#2

Hi,

Thank you for your interest in Aspose.Word.

You can use a workaround for the time being. Create a paragraph and set its bottom border to a line, then clear it in the next paragraph.

But we have logged your request and will implement it, please check back later.


#3
Dmitry's way sounds easier than what we do in our app. But in case it helps ...












//
// Embeds a
by using a standard black line image
//
private void WriteRule(DocumentBuilder wdb) {
 wdb.InsertParagraph();
//wdb.ParagraphFormat.LeftIndent = 0;
Bitmap img = new Bitmap(RuleWidth,1, PixelFormat.Format32bppArgb);
Graphics g = Graphics.FromImage(img);
SolidBrush b = new SolidBrush(Color.FromArgb(102,122,132));
g.FillRectangle(b,0,0,RuleWidth,1);
 wdb.InsertImage(img);
}
//RuleWidth is in pixels, i think.

David

#4

Anyway, we are going to implement


support soon. Then we will probably implement full horizontal line support - just like in Word.

#5

Has this support for horizontal lines been added and how does one access it??


#6

Yes, we now have support for paragraph borders, which are basically used in MS Word to draw horizontal lines in text. Here is a sample code that draws horizontal line above the first paragraph of the document:

Document doc = new Document(filename);

Paragraph paragraph = (Paragraph)doc.GetChild(NodeType.Paragraph, 0, true);

Border topBorder = paragraph.ParagraphFormat.Borders[BorderType.Top];

topBorder.Color = System.Drawing.Color.Black;

topBorder.LineStyle = LineStyle.Single;

topBorder.LineWidth = 1;