I’m using Aspose.words for Java to compare two versions of .DOCX files, but I noticed that footer content updates are not showing in the comparison output file, even though it works fine on MS Word compare.
sample code:
public static void main(String[] args) throws Exception {
String currentDirectory = System.getProperty("user.dir");
System.out.println("Checking Aspose Java library with current dir :" + currentDirectory);
loadAsposeLicense();
Document original = new Document("<file-v1>.docx");
Document revised = new Document("<file-v2>.docx");
compareDocuments(revised, original);
}
public static void compareDocuments(Document original, Document revised) throws Exception {
if (original.hasRevisions()) original.acceptAllRevisions();
if (revised.hasRevisions()) revised.acceptAllRevisions();
original.compare(revised, "Author", new java.util.Date());
original.save("<output-file-name>.docx");
System.out.println("Comparison completed. Result saved.");
}
It seems that the footer content updates are not being reflected in the comparison output file when using Aspose.Words for Java. This issue may arise due to the default comparison settings, which might be ignoring certain elements like headers and footers.
To ensure that footer changes are included in the comparison, you can utilize the CompareOptions class to adjust the comparison settings. Specifically, you should set the IgnoreHeadersAndFooters option to false. Here’s how you can modify your compareDocuments method to include this option:
public static void compareDocuments(Document original, Document revised) throws Exception {
if (original.hasRevisions()) original.acceptAllRevisions();
if (revised.hasRevisions()) revised.acceptAllRevisions();
CompareOptions options = new CompareOptions();
options.setIgnoreHeadersAndFooters(false); // Ensure headers and footers are considered
original.compare(revised, "Author", new java.util.Date(), options);
original.save("<output-file-name>.docx");
System.out.println("Comparison completed. Result saved.");
}
By setting IgnoreHeadersAndFooters to false, the comparison will take into account any changes made in the footers, which should resolve the issue you are experiencing.
Make sure to test this adjustment with your documents to verify that the footer updates are now reflected in the output file. If you continue to face issues, consider checking the specific content of the footers in both documents to ensure they are being recognized correctly by the library.
@Kldv
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-28035
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@Kldv
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-28029
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
Hi @alexey.noskov I noticed that the stories created for your internal tracking systems are marked as closed. Could you provide an update on this? what is causing these issues, and are there any steps we need to follow to prevent them?
@Kldv Yes, both issue are already resolved. The fixes will be available in the next 25.4 version of Aspose.Words. We will be sure to let you know once it is released. Usually java releases are published in the middle of each month.
We have encountered an issue similar to WORDSNET-28035 (tag updates in footer not coming). Could you please check the provided files and let us know if it is resolved with the latest changes of v25.4, or if it is a new issue that needs to be addressed?
Observation:
on the first page, Aspose isn’t showing the data in the title and subtitle tags in the document body, but MS Word displays them correctly.
@Kldv
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-28117
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@Kldv We have completed analyzing WORDSNET-28117. You should use ComparisonTargetType.New to get desired output (MS Word compares this case in different way depending on target type). Currently Subject property is not processed but Title property is already handled properly.
CompareOptions compareOptions = new CompareOptions() { Target = ComparisonTargetType.New };
Document v1 = new Document(@"C:\Temp\v1.docx");
Document v2 = new Document(@"C:\Temp\v2.docx");
v1.Compare(v2, "test", DateTime.Now, compareOptions);
v1.Save(@"C:\Temp\out1.docx");