Does Granularity.WordLevel apply to headers and footers during document comparison

Does Granularity.WordLevel apply to headers and footers during document comparison

@ankur101010

Yes, Granularity.WordLevel does apply to headers and footers during document comparison. When this granularity setting is enabled, the comparison process analyzes text at the word level, which includes all sections of the document, such as headers and footers. This ensures that any differences in wording or formatting within these areas are accurately identified. If you have further questions about document comparison features, feel free to ask.

Best regards,
Professionalize.Discourse Bot

But it is not applying in Header. Whereas in body it is applying correclty

@ankur101010 Could you please attach your problematic input and output documents here for testing? We will check the issue and provide you more information.

BaseDocument.docx (30.2 KB)

DocuemntToBeCompared.docx (30.3 KB)

Word_Compare_Image

Code used to compare:-

 public async Task<byte[]> Compare(Document document1, Document document2, string userName)
 {
     Aspose.Words.Comparing.CompareOptions compareOptions = new Aspose.Words.Comparing.CompareOptions
     {
         IgnoreFormatting = false,
         IgnoreCaseChanges = false,
         IgnoreTables = false,
         IgnoreFields = false,
         IgnoreFootnotes = false,
         IgnoreComments = false,
         IgnoreTextboxes = false,
         IgnoreHeadersAndFooters = false,
         Granularity = Granularity.WordLevel,
         CompareMoves = true
     };
     document1.AcceptAllRevisions();
     document2.AcceptAllRevisions();
     document1.TrackRevisions = true;

     // Compare the documents and track revisions
     document1.Compare(document2, userName, DateTime.Now, compareOptions);

     using (MemoryStream memoryStream = new MemoryStream())
     {
         // Save the compared document to memory stream
         document1.Save(memoryStream, SaveFormat.Docx);
         memoryStream.Position = 0;
         return await Task.FromResult<byte[]>(memoryStream.ToArray());
     }
 }

@ankur101010 The following code produces the same output as MS Word comparison on my side:

CompareOptions opt = new CompareOptions();
opt.Granularity = Granularity.WordLevel;
opt.Target = ComparisonTargetType.New;

Document v1 = new Document(@"C:\Temp\BaseDocument.docx");
Document v2 = new Document(@"C:\Temp\DocuemntToBeCompared.docx");
v2.Compare(v1, "AW", DateTime.Now, opt);
v2.Save(@"C:\Temp\out.docx");

MS Word: ms.docx (30.3 KB)
Aspose.Words: out.docx (23.2 KB)

*In the code you suggested, when we add new text to “DocumentsToBeCompared.docx” and then perform a comparison, the output document incorrectly shows the newly added text as struck through. This is misleading, as the text was actually added, not removed. *

@ankur101010
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-28664

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.