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.

MethodWhichWillResultTheEntireContent, header footer

Thread ID:

Created:

Updated:

Platform:

Replies:

126382 Oct 12,2016 08:35 AM Oct 14,2016 04:09 AM ASP.NET MVC 6
loading
Tags: DocIO
New Tester
Asked On October 12, 2016 08:35 AM

WordDocument wordDokument = new WordDocument();
wordDokument.Open(someStream, FormatType.Docx);
wordDokument.Replace("someString", MethodWhichWillResultTheEntireContent(), false, false);
IWSection section = wordDokument.AddSection();
IWParagraph tableHeaderParagraph = section.HeadersFooters.Header.AddParagraph();



For example "MethodWhichWillResultTheEntireContent()" has may be 10 pages, but when I insert Header/Footer it will append it to the last document and not all pages(including from "MethodWhichWillResultTheEntireContent()").

How can I set header and footer for pages including which come from "MethodWhichWillResultTheEntireContent()" ?

Priyanga Elangovan [Syncfusion]
Replied On October 13, 2016 03:05 AM

Hi Customer,

Thank you for contacting Syncfusion support.

On further analyzing on the given code snippet, we found that you are replacing the Word document content using WordDocument.Replace method, after that you have added the new section to the Word document and set the headerfooter for this newly added section. So that, the headerfooter contents are preserved only for the pages in that newly added section. If your requirement is to set the headerfooter for all the pages in the document means, then you need to set the headerfooter for the lastsection of the document before adding the new section to the document. We have prepared the sample to illustrate the same. Please find the sample from below link.

Sample Link:
http://www.syncfusion.com/downloads/support/forum/126382/ze/Sample-1122826598.zip

As per the Microsoft Word behaviour Essential DocIO supports the following header footer types.

      1. First Page Header and First Page Footer
      2. Odd Header and Odd Footer
      3. Even Header and Even Footer

You can make use of the above header footer types using DocIO. Kindly refer the below UG documentation link to know more about Header and Footers.

UG documentation link:
http://help.syncfusion.com/ug/windows%20forms/default.htm#!documents/headersandfooters.htm

Regards,
Priyanga.E

 


New Tester
Replied On October 13, 2016 04:43 AM

"Default1Controller.cs" is not avaiable in the solution, but even I take a look at the file in the folder, there is actually no reference to my requst.

No my code looks like this:


        private void InitMethod()
        {

            WordDocument word = new WordDocument();
            word.Open(someStream, FormatType.Docx);
            word.Replace("someString", MethodWhichWillResultTheEntireContent(), false, false);

        }

        private WordDocument MethodWhichWillResultTheEntireContent()
        {

            WordDocument word = new WordDocument();

            word.EnsureMinimal();

            WParagraph p1 = word.LastSection.AddParagraph() as WParagraph;
            WParagraph p1graph = word.LastSection.HeadersFooters.Header.AddParagraph() as WParagraph;
            p1graph.AppendText("Header footer");//this is NOT visible in the document


            p1.AppendText("first page"); //this is visible in the document

            return word;
        }
        
Right now I do not even get the header/footer.

Vijay Ramachandran [Syncfusion]
Replied On October 13, 2016 09:30 AM

Hi Customer,

Thank you for your information.

As per the behaviour of WordDocument.Replace() method, it replaces the text with document text body items only and it won’t replace the sections header footer. So that the header and footer contents are not copied to the source document.

Kindly provide confirmation on whether your requirement is adding same header and footer contents to all of the pages in result Word document or only at particular section headers and footers which have the replacing text and also provide the input Word document along with complete code snippets. So that we can analyse further and provide you the appropriate solution as much early as possible.

Regards,
Vijay R
 


New Tester
Replied On October 13, 2016 10:14 AM

"adding same header and footer contents to all of the pages in result Word document". thanks

Vijay Ramachandran [Syncfusion]
Replied On October 14, 2016 01:37 AM

Hi Customer,

Thank you for your update.

We have prepared the sample as per your requirement, in this sample we have replaced the particular text with new word document which have multiple pages using
WordDocument.Replace() method. After that to preserve the header and footer in each page, we have iterated all the sections in the source Word document and added the text for each section header footers. Please find the sample from the below link:
http://www.syncfusion.com/downloads/support/forum/126382/ze/Sample2061593386.zip

Let us know if you have any concern.

Regards,
Vijay R
 


New Tester
Replied On October 14, 2016 04:09 AM

thank you :)

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.

;