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.

Insert Text At Specific Location of Header (x,y)

Thread ID:

Created:

Updated:

Platform:

Replies:

131253 Jun 30,2017 10:57 AM Jul 4,2017 01:02 AM Windows Forms 6
loading
Tags: DocIO
Nilofer
Asked On June 30, 2017 10:57 AM

Dears, How do we insert Text at a specific Location let's say inside  Header of document only visible on only first Page.

Best Regards,

Nilofer
Replied On June 30, 2017 12:38 PM

Ok, some how got it done using & Text Box & below code; but how do we change font & color?

Dim txtSrNo As IWTextBox = (wordDocument.LastParagraph.AppendTextBox(300, 25))
'Set the alignment positions for text box using TextBoxFormat instance.
txtSrNo.TextBoxFormat.VerticalOrigin = VerticalOrigin.Page
txtSrNo.TextBoxFormat.VerticalPosition = 100
txtSrNo.TextBoxFormat.HorizontalOrigin = HorizontalOrigin.Page
txtSrNo.TextBoxFormat.HorizontalPosition = 100
txtSrNo.TextBoxFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText
txtSrNo.TextBoxFormat.NoLine = True
'Add the text inside the textbox textbody.
Dim textRange As IWTextRange = txtSrNo.TextBoxBody.AddParagraph().AppendText(x_SerialNo)

Nilofer
Replied On June 30, 2017 02:09 PM

Ok, Got it done! Just posting solution in case for someone similar problem

'Add the text box in particular size.

Dim txtSrNo As IWTextBox = (wordDocument.LastParagraph.AppendTextBox(240, 25)) 'Set the alignment positions for text box using TextBoxFormat instance. txtSrNo.TextBoxFormat.VerticalOrigin = VerticalOrigin.Page txtSrNo.TextBoxFormat.VerticalPosition = 129 txtSrNo.TextBoxFormat.HorizontalOrigin = HorizontalOrigin.Page txtSrNo.TextBoxFormat.HorizontalPosition = 350 txtSrNo.TextBoxFormat.TextWrappingStyle = TextWrappingStyle.InFrontOfText txtSrNo.TextBoxFormat.NoLine = True 'Add the text inside the textbox textbody. Dim textRange As IWTextRange = txtSrNo.TextBoxBody.AddParagraph().AppendText(x_SerialNo) With textRange .CharacterFormat.Bold = True .CharacterFormat.FontName = "Courier New" .CharacterFormat.TextColor = Color.Red End With

Nilofer
Replied On July 2, 2017 10:17 AM

This works well if one Page, but how to do in case of multiple pages :( This code is inserting on the last page.

I need it to insert only on First Page. Please Help.

Best Regards,


Sethumanikkam Yogendran [Syncfusion]
Replied On July 3, 2017 01:23 AM

Hi Nilofer,

Thank you for contacting Syncfusion support.

You can insert the text box in first page header of the Word document and set DifferentFirstPage Property as true from WPageSetup Class to meet your requirement. Please find the below code snippets for your reference.
 
' Sets DifferentFirstPage as true for inserting header and footer text.
wordDocument.Sections(0).PageSetup.DifferentFirstPage = True
' Inserts the text box in first page header.
Dim txtSrNo As IWTextBox = wordDocument.Sections(0).HeadersFooters.FirstPageHeader.AddParagraph().AppendTextBox(240, 25) 

Please refer the below UG link to know more about working with headers and footers.
https://help.syncfusion.com/file-formats/docio/working-with-sections#working-with-headers-and-footers

Please let us know if you have any other questions.

Regards,
Sethumanikkam.Y


Nilofer
Replied On July 3, 2017 11:55 PM

Thanks. It has been resolved.


Sethumanikkam Yogendran [Syncfusion]
Replied On July 4, 2017 01:02 AM

Hi Nilofer,

Thank you for your update.

We are glad to know that your issue has been resolved.

Please let us know if you need any further assistance. We are happy to assist you as always.

Regards,
Sethumanikkam.Y


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.

;