Horizontal line followed by text

Hi,

I have a requirement to create a horizontal line followed by text i.e --------------------Aspose Word. The trick here is the size of text may vary but the line followed by text should fit into the same line. Can you please help me out !!!

Hi Sridhar,

Thanks for your inquiry. Please use following code example to achieve your requirements. Hope this helps you.

If you still face problem, please attach your input and expected output Word documents here for our reference. We will then provide you more information about your query along with code.

Document doc = new Document(MyDir + "Test003.docx");
// Get the third paragraph of document
Paragraph paragraph = (Paragraph)doc.GetChild(NodeType.Paragraph, 2, true);
RenderedDocument layoutDoc = new RenderedDocument(doc);
int lines = layoutDoc.GetLayoutEntitiesOfNode(paragraph).Count;
while (true)
{
    layoutDoc = new RenderedDocument(doc);
    if (layoutDoc.GetLayoutEntitiesOfNode(paragraph).Count == lines + 1)
    {
        paragraph.LastChild.Remove();
        break;
    }
    paragraph.AppendChild(new Run(doc, "-"));
}
doc.Save(MyDir + "Out.docx");