We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Complete line of text with underline

Thread ID:





123981 May 5,2016 12:21 PM UTC May 6,2016 09:53 AM UTC ASP.NET MVC 1
Tags: DocIO
Andrea Perazzolo
Asked On May 5, 2016 12:21 PM UTC

I am trying, in a generated word document, to fill a paragraphwith underline, till the right margin of the paragraph.
Is it possible in any way with DocIO?

Like this:

Name: _____________________________________________________
Last Name: ________________________________________________

The lines are automatically length till the right margin.

   Thanks in advance

   Andrea Perazzolo

Suganya Rathinam [Syncfusion]
Replied On May 6, 2016 09:53 AM UTC

Hi Andrea,

Thank you for contacting Syncfusion support.

On analyzing further we found that your requirement is to fill the remaining area after the text in the paragraph with an underline till the right margin of the document. We can achieve this by adding a tab next to the text with tab leader as single and the tab stop position should be the right margin of the page. Please find the following code snippets for your reference.
//Create a new Word document 
WordDocument document = new WordDocument(); 
//Add new section to the Word document 
IWSection section= document.AddSection(); 
//Set the page margins for the section 
section.PageSetup.Margins.All = 72; 
//Add new paragraph to the document 
IWParagraph paragraph = section.AddParagraph(); 
//Get the width of the document body excluding the margins.  
//This width should be set as the tab stop position to get the line till the right margin of the page 
float tabWidth = section.PageSetup.ClientWidth; 
//Append the text to the paragraph 
paragraph.AppendText("Name: "); 
//Add a tab to the paragraph specifying the tab width, tab justification, and tab leader 
paragraph.ParagraphFormat.Tabs.AddTab(tabWidth, TabJustification.Left, TabLeader.Single); 
//Append tab to the paragraph 
paragraph = section.AddParagraph(); 
paragraph.AppendText("Last Name: "); 
paragraph.ParagraphFormat.Tabs.AddTab(tabWidth, TabJustification.Left, TabLeader.Single); 
//Save the Word document 
//Close the document instance  



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon