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.
Unfortunately, activation email could not send to your email. Please try again.

Complete line of text with underline

Thread ID:

Created:

Updated:

Platform:

Replies:

123981 May 5,2016 08:21 AM May 6,2016 05:53 AM ASP.NET MVC 1
loading
Tags: DocIO
Andrea Perazzolo
Asked On May 5, 2016 08:21 AM

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

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

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


CONFIRMATION

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.

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.

;