Words Draw Line

Hello,
At one point code below use to draw line and show it as required in MSWord. But it seems code below is missing something and not able to draw line now. Can you please help to get line draw on the document object.
I am creating lobjLineDoc object, use same to draw line and append it later to main object where I combine all the data with line as a seperator. Please let me know if there is any workaround to get this line working back.
Thanks,
Vinay Hattarki

Dim lobjLineDoc As New Aspose.Words.Document
Dim lobjDocBuilder As Aspose.Words.DocumentBuilder = New DocumentBuilder(lobjLineDoc)
Dim lWidth As Double = lobjDocBuilder.CurrentSection.PageSetup.PageWidth
Dim lLine As New Aspose.Words.Drawing.Shape(lobjLineDoc, Drawing.ShapeType.Line)
lLine.Width = lWidth / 2
lLine.HorizontalAlignment = Drawing.HorizontalAlignment.Center
lLine.StrokeColor = Color.Black
lLine.Stroke.LineStyle = Drawing.ShapeLineStyle.Single
lLine.StrokeWeight = 1
'lobjDocBuilder.CurrentSection.PageSetup.SectionStart = SectionStart.Continuous
lobjDocBuilder.InsertNode(lLine)
lobjLineDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous
lobjLineDoc.FirstSection.PageSetup.PaperSize = Aspose.Words.PaperSize.Legal
mobjMainAsposeDoc.AppendDocument(lobjLineDoc, ImportFormatMode.UseDestinationStyles)
lobjLineDoc.Save("C:\myline111.doc")
'** Temp Single Iteration Doc to get Page Count
mObjPageCountDoc.AppendDocument(lobjLineDoc, ImportFormatMode.UseDestinationStyles)

Hi
Thanks for your request. Maybe you should try using paragraph border to draw horizontal line. Please see the following code:

Dim doc As New Aspose.Words.Document
doc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.Color = Color.Black
doc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.LineStyle = LineStyle.Single
doc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.LineWidth = 2
doc.Save("C:\Temp\out.doc")

Hope this helps.
Best regards.

Hello,
I used the code you provided and modified it little. This does the same thing as my original code.
C:\MyASPoseLine.doc File was saved propery but it is not appending that objct into my main document mobjMainAsposeDoc and mObjPageCountDoc doesn’t show the line?

Dim lobjLineDoc As New Aspose.Words.Document
lobjLineDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous
lobjLineDoc.FirstSection.PageSetup.PaperSize = Aspose.Words.PaperSize.Legal
lobjLineDoc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.Color = Color.Black
lobjLineDoc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.LineStyle = LineStyle.Single
lobjLineDoc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.LineWidth = 3
lobjLineDoc.Save("C:\MyASPoseLine.doc")
mobjMainAsposeDoc.AppendDocument(lobjLineDoc, ImportFormatMode.UseDestinationStyles)
mObjPageCountDoc.AppendDocument(lobjLineDoc, ImportFormatMode.UseDestinationStyles)

Hi
Thanks for your request. I cannot reproduce the problem. Could you please attach a sample document for testing? I will investigate the issue and provide you more information.
Best regards.

I was able to get the line working but I did not find any property which makes the length of line short size and make the line to be center. I had property to do that with Shape class as per my original 1st post? Is thr any way to change the length of line and align the line to center ?

Dim lobjLineDoc As New Aspose.Words.Document
lobjLineDoc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous
lobjLineDoc.FirstSection.PageSetup.PaperSize = Aspose.Words.PaperSize.Legal
lobjLineDoc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.Color = Color.Black
lobjLineDoc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.LineStyle = LineStyle.Single
lobjLineDoc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.LineWidth = 1
' '' ''lobjLineDoc.Save("C:\MyASPoseLine.doc")
mobjMainAsposeDoc.AppendDocument(lobjLineDoc, ImportFormatMode.UseDestinationStyles)
mObjPageCountDoc.AppendDocument(lobjLineDoc, ImportFormatMode.UseDestinationStyles)

Hi
Thanks for your request. You can try playing with margins. Please see the following code:

Dim mainDoc As New Document
Dim doc As New Aspose.Words.Document
doc.FirstSection.PageSetup.SectionStart = SectionStart.Continuous
doc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.Color = Color.Black
doc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.LineStyle = LineStyle.Single
doc.FirstSection.Body.FirstParagraph.ParagraphFormat.Borders.Bottom.LineWidth = 2
'Set margins
doc.FirstSection.PageSetup.LeftMargin = 200
doc.FirstSection.PageSetup.RightMargin = 200
mainDoc.AppendDocument(doc, ImportFormatMode.UseDestinationStyles)
mainDoc.Save("C:\Temp\out1.doc")

Hope this helps.
Best regards.