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 Oct 25, 2017 8:05 pm
We have a program merging multiple word templates. The problem we are coming up across is merging a doc with a header with one that doesnt have a header. The document with no header encorporates the first documents header. Is there any way to merge these two documents. If we merge two headers it works fine.
Thank You
-
caticsteve
-
- Posts: 6
- Joined: Wed Oct 11, 2017 4:21 pm
Thu Oct 26, 2017 3:09 am
Hello caticsteve,
Thanks for your inquiry.
You could use the property "LinkToPrevious"to manipulate the header.
Please refer to the following code.
- Code: Select all
Document document = new Document();
document.LoadFromFile("NoHeader.docx", FileFormat.Docx);
document.InsertTextFromFile("WithHeader.docx", FileFormat.Docx);
document.Sections[document.Sections.Count - 1].HeadersFooters.LinkToPrevious = false;
document.InsertTextFromFile("NoHeader.docx", FileFormat.Docx);
document.Sections[document.Sections.Count - 1].HeadersFooters.LinkToPrevious = false;
document.SaveToFile("MergedFile.docx", FileFormat.Docx);
Sincerely,
Jane
E-iceblue support team
-
Jane.Bai
-
- Posts: 1156
- Joined: Tue Nov 29, 2016 1:47 am
Wed Nov 01, 2017 8:45 am
Hi,
Greetings from E-iceblue!
Has your issue been resolved?
Thanks in advance for your valuable feedback and time.
Sincerely,
Jane
E-iceblue support team
-
Jane.Bai
-
- Posts: 1156
- Joined: Tue Nov 29, 2016 1:47 am
Wed Nov 01, 2017 2:16 pm
I will update once development gets back to me.
-
caticsteve
-
- Posts: 6
- Joined: Wed Oct 11, 2017 4:21 pm