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

add section in the middle of document without header

hi,
i have a document with two type of header, the first is in the first page and the second header in the other page.
i want to add section in a specific emplacement.
and the section added don't contain any header.
thanks.

5 Replies

AT AtliDev June 7, 2019 09:40 AM UTC

hi,
i want to delete my header from my current section.

Dim header As DLS.HeaderFooter = a.Sections(1).HeadersFooters.Header
        For i = 0 To header.ChildEntities.Count - 1
            header.ChildEntities.RemoveAt(0)
Next

this code is not working at the seconde section

thanks


VA Vijayasurya Anandhan Syncfusion Team June 7, 2019 02:02 PM UTC

Hi AtliDev,

Thank you for contacting Syncfusion support.

To meet your requirement, we have prepared a sample. Please find the sample from the below link:
http://www.syncfusion.com/downloads/support/forum/145101/ze/Sample1869621340.zip

In this sample, we have done the following things:
1. Created a new Word document.
2. Add new section to the document.
3. Add new paragraph to the section.
4. Add header and footer to the section with page break.
5. Created new section to the document.
6. Add new paragraph to the second section.
7. Add header and footer to the second section with page break.
8. Iterated the section to get the current section
9. Removed the child entities of the header in the second section.
10. Saved the document.

If you are facing any problem while using this scenario at your end. We request you to share the input word document used in your end and the expeted output Word document. Thereby, we will check on your problem and will provide you the appropriate solution at the earliest.

Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to achieve your end requirements. 


Regards,
Vijayasurya A



AT AtliDev June 18, 2019 02:59 PM UTC

hi,
a.Sections(0).PageSetup.DifferentOddAndEvenPages is not working when i have 4 or more section , the other section have a different header then the first one
for my case i have a document , in the attach , contains 3 sections and i just want to delete the header in the second section.

the code you give me , you create a new worddocument , is not the same.

the code i use it, but is not working !!

       Dim a As WordDocument = New WordDocument(chemin + "\testword\Template123.doc", FormatType.Doc)

        For i As Integer = 0 To a.Sections(1).HeadersFooters.EvenHeader.ChildEntities.Count - 1
            a.Sections(1).HeadersFooters.Header.ChildEntities.RemoveAt(0)
        Next

        For i As Integer = 0 To a.Sections(1).HeadersFooters.FirstPageHeader.ChildEntities.Count - 1
            a.Sections(1).HeadersFooters.Header.ChildEntities.RemoveAt(0)
        Next

        For i As Integer = 0 To a.Sections(1).HeadersFooters.Header.ChildEntities.Count - 1
            a.Sections(1).HeadersFooters.Header.ChildEntities.RemoveAt(0)
        Next

        For i As Integer = 0 To a.Sections(1).HeadersFooters.OddHeader.ChildEntities.Count - 1
            a.Sections(1).HeadersFooters.Header.ChildEntities.RemoveAt(0)
        Next

thanks for help


Attachment: sample_b9ea9141.zip


MJ Mohanaselvam Jothi Syncfusion Team June 19, 2019 09:09 AM UTC

Hi AtliDev,

Thank you for your update.

From the given details, we have found that your requirement is to set different header and footer for first page and to remove header and footer for particular section in the Word document. To set different header and footer for first page, we suggest you to add header and footer contents in FirstPageHeader and FirstPageFooter. To remove header and footer for the particular section, we suggest you to set empty paragraph in the headers and footer of section. We have prepared the sample for the same and it can be downloaded from the below link:
http://www.syncfusion.com/downloads/support/forum/145101/ze/Sample-1683304921

Please let us know if you have any other questions.

Regards,
Mohanaselvam J 



AT AtliDev June 19, 2019 09:25 AM UTC

thanks,
the same solution i found yesterday,
i clear my header and i insert paragraph in

     a.Sections(1).HeadersFooters.Header.ChildEntities.Clear()
     a.Sections(1).HeadersFooters.Header.AddParagraph()

thanks for help.

Loader.
Live Chat Icon For mobile
Up arrow icon