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. Image for the cookie policy date

Complete line of text with underline

Hi,
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

1 Reply

SR Suganya Rathinam Syncfusion Team 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.AppendText("\t"); 
paragraph = section.AddParagraph(); 
paragraph.AppendText("Last Name: "); 
paragraph.ParagraphFormat.Tabs.AddTab(tabWidth, TabJustification.Left, TabLeader.Single); 
paragraph.AppendText("\t"); 
//Save the Word document 
document.Save("Sample.docx"); 
//Close the document instance  
document.Close(); 


Regards,
Suganya


Loader.
Live Chat Icon For mobile
Up arrow icon