Hi,
I am having the following Issue with Aspose.Words for Java:
When opening a docx file with 2 sections, where the header of section 2 is linked to the header of section 1 and then saving the file as copy, I get a file with an empty header in section 2 instead of the linked content of header 1.
The following code example demonstrates the issue (executed with version 23.5):
package com.sample;
import com.aspose.words.Document;
import com.aspose.words.HeaderFooter;
import com.aspose.words.HeaderFooterType;
import com.aspose.words.Section;
import org.junit.jupiter.api.Test;
public class LinkedHeaderTest {
@Test
void headerOfSection2ShouldBeLinkedToHeaderOfSection1() throws Exception {
Document document = new Document("C:\\work\\projects\\various\\aspose_words\\src\\test\\resources\\linked.docx");
int i = 0;
for (Section section : document.getSections()) {
System.out.println("############ Section " + ++i);
HeaderFooter headerPrimary = section.getHeadersFooters().getByHeaderFooterType(HeaderFooterType.HEADER_PRIMARY);
System.out.println("HEADER_PRIMARY: isLinkedToPrevious: " + headerPrimary.isLinkedToPrevious());
System.out.println("content: " + headerPrimary.getFirstParagraph().getText());
}
document.save("C:\\work\\projects\\various\\aspose_words\\src\\test\\resources\\linked_copy.docx");
}
}
This produces the following output, that also shows, that the information that the header of section 2 is linked to the header of section 1 is not present:
############ Section 1
HEADER_PRIMARY: isLinkedToPrevious: false
content: Header for Section 1 and Section 2
############ Section 2
HEADER_PRIMARY: isLinkedToPrevious: false
content:
Please find this sample attached as .zip aspose_words.zip (41.1 KB)