Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Wed May 31, 2017 11:57 pm

Dear Support Team,

First of all, I would like to thank you for this amazing tool.

We are developing a solution which will support report generation through word documents and we found all we need but
still one more key feature for us we wanted to ask you if it's supported or not.

Is it possible to modify the header based on a condition on a page?
in other way is it possible to add different page header per page?


Thanks and Best Regards,

mohamed.gamal323
 
Posts: 3
Joined: Mon May 29, 2017 9:07 am

Thu Jun 01, 2017 7:15 am

Dear mohamed.gamal323,

Thanks for your inquiry.
Sorry that there is no direct way to set different header per page, but there is a solution might meet your requirement. Please add new section which only includes one page, and then set the LinkToPrevious as false. Then you could set different header for every section. Sample code for your kind reference.
Code: Select all
            Document doc = new Document();
            Section sec1 = doc.AddSection();
            sec1.HeadersFooters.Header.AddParagraph().AppendText("Header1");
            Section sec2 = doc.AddSection();
            sec2.HeadersFooters.LinkToPrevious = false;
            sec2.HeadersFooters.Header.AddParagraph().AppendText("Header2");
            Section sec3 = doc.AddSection();
            sec3.HeadersFooters.LinkToPrevious = false;
            sec3.HeadersFooters.Header.AddParagraph().AppendText("Header3");
            doc.SaveToFile("10712Result.docx", Spire.Doc.FileFormat.Docx);

If there is any question, please let me know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Jun 01, 2017 9:15 am

Dear Betsy.jiang,

Thanks for your quick response.
This solution may meet our requirements on condition ( if we can extract the contents of specific page).
We have one section in the document which include one paragraph, this paragraph may be too large that it can take more than one page.
So I can create a document consists of 3 pages for example with the same header and footer. then if i can traverse the pages of this document and get the contents of it and put each one in a new section to be able to modify the headers and footers then it will be great.

So, can we traverse the pages of the document?

Best Regards,

mohamed.gamal323
 
Posts: 3
Joined: Mon May 29, 2017 9:07 am

Thu Jun 01, 2017 9:40 am

Dear mohamed.gamal323,

Thanks for your feedback.
I am afraid that traversing the pages of the document is impossible, since MS Word document is flow document and does not contain any information about its layout into lines and pages.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Thu Jun 01, 2017 12:13 pm

Dear Betsy,

Can we achieve this requirements using formula? Do you support it?

Best Regards,

mohamed.gamal323
 
Posts: 3
Joined: Mon May 29, 2017 9:07 am

Fri Jun 02, 2017 2:19 am

Hello,

I am afraid that this is also impossible. MS Word document is flow document and does not contain any information about its layout into pages, so you cannot determine where page starts or ends, therefore, you cannot split your document into pages but splitting it by Sections.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Return to Spire.Doc