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

Change position of WTextBox

hi,
I have a document with a WTextBox in the HeadersFooters , when i change the PageSize and the Orientation of the document the WTextBox change the position.
So i tried to reposition the WTextBox by code but it doesn't work.
How can i do this ? Thanks 
The code that i use:
     
     For Each _section As WSection In a.Sections
            _section.PageSetup.PageSize = PageSize.A3
            _section.PageSetup.Orientation = PageOrientation.Landscape
            For Each _element As Entity In _section.HeadersFooters.EvenHeader.ChildEntities
                If TypeOf _element Is WParagraph Then
                    ShapeTestChangePosition(_element)
                End If
            Next
            For Each _element As Entity In _section.HeadersFooters.FirstPageHeader.ChildEntities
                If TypeOf _element Is WParagraph Then
                    ShapeTestChangePosition(_element)
                End If
            Next
            For Each _element As Entity In _section.HeadersFooters.Header.ChildEntities
                If TypeOf _element Is WParagraph Then
                    ShapeTestChangePosition(_element)
                End If
            Next
            For Each _element As Entity In _section.HeadersFooters.OddHeader.ChildEntities
                If TypeOf _element Is WParagraph Then
                    ShapeTestChangePosition(_element)
                End If
            Next
        Next


The function :

Private Sub ShapeTestChangePosition(ByVal _element As WParagraph)
        Dim para As WParagraph = _element
        For Each _sselement As Entity In para.ChildEntities
            If TypeOf _sselement Is WTextBox Then
                Dim _textbox As WTextBox = _sselement
                     _textbox.TextBoxFormat.HorizontalPosition = HorizontalPosition.Right
                     _textbox.TextBoxFormat.VerticalPosition = VerticalPosition.Bottom
                     _textbox.TextBoxFormat.VerticalOrigin = VerticalOrigin.Margin
                     _textbox.TextBoxFormat.HorizontalOrigin = HorizontalOrigin.Page
            End If
        Next




u will found attached the document.

Thanks for help



Attachment: exemple1_243674c2.rar

7 Replies

SB Suriya Balamurugan Syncfusion Team November 22, 2019 03:00 AM

Hi AtliDev,

Thank you for contacting Syncfusion support.

On analysing further, we have found that the input Word document textbox have horizontal position with respect to column and vertical position with respect to page. In Microsoft Word, while changing page size and orientation, to preserve the textbox in right - bottom corner of the page means sets the textbox position with respect to right - bottom margin which is not supported by Microsoft Word in DOC format. So we positioned the textbox to right – bottom corner of the page as per your requirement by calculating the page size.

We have prepared a sample application to change the position of the textbox as per your requirement and it can be downloaded from the below link:

https://www.syncfusion.com/downloads/support/forum/149304/ze/VB_Windows1895570612

Note: Please find the template Word document in “Data” folder of above sample application.

In the above sample, we have done the following things:
  1. Loads the input Word document.
  2. Changes the page size and orientation of the Word document.
  3. Gets the value of page size before and after changing the page size and orientation.
  4. Iterates to the corresponding textbox.
  5. Gets the position of the textbox.
  6. Calculates the new position of the textbox from the page size.
  7. Sets the new position values to the textbox.
  8. Saves the Word document.

Please let us know if you have any other questions.

Regards,
Suriya Balamurugan.



AT AtliDev November 22, 2019 04:58 AM

Hi,

Thanks for helping , 
i will try the proposed step, but i didn't found the code in the given sample.

thanks.


SR Suganya Rathinam Syncfusion Team November 25, 2019 03:39 AM

Hi AtliDev,

Thanks for the update.

In the provided sample the method btnCreate_Click() in the file Form1.Designer.vb will have the code to position the textbox in the Word document. Please try running the provided sample and let us know whether it helps.

Regards,
Suganya R



AT AtliDev November 28, 2019 05:53 AM

hi,
thanks for help. the positionnement of textbox is work now.
but the problem is came from linktoprevious , if my section has headersfooters link to previous = true , nothing is change.

i found also a problem when i do my test : 
( if my second section linktoprevious = false , and we force changing a other time linktoprevious to false , i found a header or footer with double contents )

thanks for help
AtliDev


SR Suganya Rathinam Syncfusion Team November 29, 2019 12:41 AM

Hi AtliDev,

Thank you for the update.

We tried to reproduce the mentioned Header/Footer difference with the provided details. But the result is preserved as expected. Please find the sample we tried from the following link.

https://www.syncfusion.com/downloads/support/forum/149304/ze/VB_Windows1895570612-1549194220

Kindly modify the sample with the input document used, and the code snippets tried at your end and share the same. We will analyze further on that and update you the details.

Regards,
Suganya R



AT AtliDev November 29, 2019 01:30 AM

hi, 

thanks for update,

you need to have the second section in the document with link to previous false ( i attach the document for test )
and if by code you force the section to change linktoprevious = false you will see the double header and footer.

thanks.


Attachment: Test_5c287b54.rar


SR Suganya Rathinam Syncfusion Team December 2, 2019 03:34 AM

Hi AtliDev,

Thank you for the update.

We can reproduce the mentioned issue in the header/footer when the LinkToPrevious is set to false. We confirmed it as defect and the fix for this issue will be included in our 2019 Volume 4 release which is expected to be available in the mid of December 2019.

The status of the issue can be tracked with the following link:
https://www.syncfusion.com/feedback/10520/header-footer-gets-duplicated-when-linktoprevious-is-diabled


Regards,
Suganya R


Loader.
Live Chat Icon For mobile
Up arrow icon