Hello,
Aspose Words fails with “IndexOutOfBoundsException” when using compare method on documents with varying header/footer “link to previous” option:
// Document A
Document documentA = new Document();
DocumentBuilder builder = new DocumentBuilder(documentA);
Section currentSection = builder.getCurrentSection();
PageSetup pageSetup = currentSection.getPageSetup();
pageSetup.setDifferentFirstPageHeaderFooter(false);
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
builder.writeln("H/F PRIM");
builder.moveToHeaderFooter(HeaderFooterType.HEADER_FIRST);
builder.writeln("H/F FP");
builder.moveToDocumentEnd();
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
currentSection = builder.getCurrentSection();
pageSetup = currentSection.getPageSetup();
pageSetup.setDifferentFirstPageHeaderFooter(true);
documentA.getSections().get(1).getHeadersFooters().linkToPrevious(false);
// Document B
Document documentB = new Document();
builder = new DocumentBuilder(documentB);
currentSection = builder.getCurrentSection();
pageSetup = currentSection.getPageSetup();
pageSetup.setDifferentFirstPageHeaderFooter(false);
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
builder.writeln("H/F PRIM");
builder.moveToHeaderFooter(HeaderFooterType.HEADER_FIRST);
builder.writeln("H/F FP");
builder.moveToDocumentEnd();
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
currentSection = builder.getCurrentSection();
pageSetup = currentSection.getPageSetup();
pageSetup.setDifferentFirstPageHeaderFooter(true);
documentB.getSections().get(1).getHeadersFooters().linkToPrevious(true);
// Comparison
documentA.compare(documentB, "Author", Calendar.getInstance().getTime()); // --> Exception