Compare Documents gives different results in PDF and Word

Hello,

I am trying to perform compare of documents with page numbers and I notice I receive different results in PDF and Word. Below you can found 2 problems which I found:

Comparing document without page numbers and one with page numbers give different result if we use custom page number style:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
doc.updateFields();

Document doc2 = new Document();
DocumentBuilder builder2 = new DocumentBuilder(doc2);
builder2.getPageSetup().setRestartPageNumbering(true);
builder2.getPageSetup().setPageStartingNumber(3);
builder2.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
builder2.getPageSetup().setPageNumberStyle(NumberStyle.UPPERCASE_ROMAN);
builder2.insertField("PAGE");
doc2.updateFields();

CompareOptions compareOptions = new CompareOptions();
compareOptions.setGranularity(Granularity.CHAR_LEVEL);
compareOptions.setIgnoreDmlUniqueId(true);

doc.compare(doc2, " ", Calendar.getInstance().getTime(), compareOptions);
doc.save("a.pdf");
doc.save("a.docx");

Gives results like that:

So it looks like style is not kept in PDF

When we try to compare 2 files with only difference in page number style we receive output like nothing change.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.getPageSetup().setRestartPageNumbering(true);
builder.getPageSetup().setPageStartingNumber(3);
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
builder.getPageSetup().setPageNumberStyle(NumberStyle.ARABIC);
builder.insertField("PAGE");
doc.updateFields();

Document doc2 = new Document();
DocumentBuilder builder2 = new DocumentBuilder(doc2);
builder2.getPageSetup().setRestartPageNumbering(true);
builder2.getPageSetup().setPageStartingNumber(3);
builder2.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
builder2.getPageSetup().setPageNumberStyle(NumberStyle.UPPERCASE_ROMAN);
builder2.insertField("PAGE");
doc2.updateFields();

CompareOptions compareOptions = new CompareOptions();
compareOptions.setGranularity(Granularity.CHAR_LEVEL);
compareOptions.setIgnoreDmlUniqueId(true);

doc.compare(doc2, " ", Calendar.getInstance().getTime(), compareOptions);
doc.save("a.pdf");
doc.save("a.docx");

Could you please make it at least consistent between word and pdf?

@ANDREA.FARRIS Thank you for reporting the problems to us.

I have logged this issue as WORDSNET-24476. We will keep you informed and let you know once it is resolved.

This is not a bug, but the expected behavior because content of the document is not changed actually. MS Word behaved the same way. For example see the following documents and the result of MS Word comparison: 1.docx (7.5 KB) 2.docx (7.5 KB) ms.docx (15.1 KB)

The issues you have found earlier (filed as WORDSNET-24476) have been fixed in this Aspose.Words for Java 22.12 update.