Compare and find the exact difference of top and left of a shape or a table in .NET

@varun.arora

Please have a look at our free support policy. I am afraid but all the free support matters are only handled over this forum.

Hello Atir,

We have got one stylechanged where all three text fields were empty. What does that imply?
What does it imply?

Change Type: StyleChanged
Change Text:
Source Text
Target Text
Change ComparisonAction: None - Change Box: X: 46.0517, Y: 111.2972, Width: 256.9165, Height: 32.98928
Property: Width - Old Value: 188.65 - New Value: 189
Property: Height - Old Value: 21.85 - New Value: 21.75

In the below screenshot of document comparison, a table was shifted into the next line. In the comparison doc it gives something changed but doesn’t tell what’s changed. Its not even being tracked in changes via APIs.
Table-reinserted-next-line.png (2.7 KB)

Regarding that demo, I am not asking for more support, I am asking for a demo so that we can decide that the product meets our requirement for massive comparison task that we have ahead. The management can then make decision to purchase the product as well as paid support.

Thanks,
Varun

@varun.arora

We’ll surely help you out here. Could you please also share those documents? We’ll compare them at our end and answer your questions in details.

Hello Atir,

  1. I am trying to compare MSWord_Template Horizontal Lines.zip (29.6 KB)
    with TextControl_Template Horizontal Lines.zip (13.7 KB)
    I am getting lots of changes for deletion of HeaderFooter.0001_GDResults_Template Horizontal Lines.zip (17.4 KB)

Can you please explain why are those entries coming?

  1. For this document comparison MSWord_Default CC Form.zip (11.8 KB)
    with TextControl_Default CC Form.zip (5.4 KB)
    the position alignment is changed DefaultCCForm.png (2.5 KB)
    I think this resultset is not tracking it. 0001_GDResults_Default CC Form.zip (1.9 KB)

My code looks like:

public int CompareDocs(Stream doc1Stream, Stream doc2Stream, string customerFolder, string templateName, string counter)
{
string extension = Utility.GetFileExtension(doc1Stream);
string outputFileName = Path.Combine($"{ Constants._ComparisonDirectoryPath}{customerFolder}\{Constants._GDResultsDirectoryNameDocx}\", $"{counter}GDResults{templateName}.{extension}");

        using (Comparer comparer = new Comparer(doc1Stream))
        {
            comparer.Add(doc2Stream);
            CompareOptions compareOptions = new CompareOptions()
            {
                InsertedItemStyle = new StyleSettings()
                {
                    HighlightColor = System.Drawing.Color.Yellow,
                    FontColor = System.Drawing.Color.DarkGreen,
                    IsUnderline = true,
                    IsBold = true,
                    IsStrikethrough = true,
                    IsItalic = true
                },
                DeletedItemStyle = new StyleSettings()
                {
                    HighlightColor = System.Drawing.Color.LightGreen,
                    FontColor = System.Drawing.Color.DarkRed,
                    IsUnderline = true,
                    IsBold = true,
                    IsStrikethrough = true,
                    IsItalic = true
                },
                ChangedItemStyle = new StyleSettings()
                {
                    HighlightColor = System.Drawing.Color.LightGray,
                    FontColor = System.Drawing.Color.DarkBlue,
                    IsUnderline = true,
                    IsBold = true,
                    IsStrikethrough = true,
                    IsItalic = true
                },
                GenerateSummaryPage = true,
                ExtendedSummaryPage = true,
                CompareVariableProperty = true,
                //CompareDocumentProperty = true,
                CompareBookmarks = true,
                SensitivityOfComparison = 100,
                HeaderFootersComparison = true,
                CalculateCoordinates = true,
                ShowDeletedContent = true,
                DetalisationLevel = DetalisationLevel.High,
                DetectStyleChanges = true,
                MarkChangedContent = true,
                MarkNestedContent = true,
                ShowInsertedContent = true
            };
            string outputTextFileName = Path.Combine($"{ Constants._ComparisonDirectoryPath}{customerFolder}\\{Constants._GDResultsDirectoryNameTxt}\\", $"{counter}_GDResults_{templateName}.txt");
            try
            {
                comparer.Compare(File.Create(outputFileName), compareOptions);
                ChangeInfo[] changes = comparer.GetChanges();
                string comparison = string.Empty;
                foreach (var change in changes)
                {
                    
                    comparison += $"Change Type: { change.Type.ToString()} {Environment.NewLine} Change Text: {change.Text} {Environment.NewLine} Source Text {change.SourceText} {Environment.NewLine} Target Text {change.TargetText} {Environment.NewLine}";
                    comparison += $"Component Type: { change.ComponentType}, Change ComparisonAction: {change.ComparisonAction.ToString()},{Environment.NewLine}";
                    comparison += $"Change Box: X: { change.Box.X.ToString() }, Y: { change.Box.Y.ToString() }, Width: { change.Box.Width.ToString() }, Height: { change.Box.Height.ToString() } {Environment.NewLine}";
                    comparison += $"Page Info: Page number - { change.PageInfo.PageNumber }, Page Width: {change.PageInfo.Width}, Page Height: {change.PageInfo.Height}{Environment.NewLine}";


                    foreach (var styleChange in change.StyleChanges)
                    {
                        comparison += $"Property: { styleChange.PropertyName} - Old Value: { styleChange.OldValue } - New Value: {styleChange.NewValue} {Environment.NewLine}";
                    }
                    comparison += $"===================================================================={Environment.NewLine}{Environment.NewLine}{Environment.NewLine}{Environment.NewLine}";
                }
                File.WriteAllText(outputTextFileName, comparison);
            }
            catch(Exception ex)
            {
                log.Error($"Error in Convertint Document: {Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.ToString()}");
                File.WriteAllText(outputTextFileName, 
                    $"Error in Converting Document: {Environment.NewLine}{ex.Message}{Environment.NewLine}{ex.ToString()}");
            }
        }
        Console.WriteLine($"\nDocuments compared successfully.\nCheck output in {Directory.GetCurrentDirectory()}.");
        return 1;
    }

Thanks,
Varun

@varun.arora

We are investigating this. The investigation ID for this issue is COMPARISONNET-2651.

This scenario is also under investigation with ticket ID COMPARISONNET-2652.
We’ll notify you as there’s any progress update.

@varun.arora

Please have a look at this screenshot.png (8.6 KB). Let us know if this is what you are expecting.

@Atir_Tahir If you see the documents side by side, whole table is shifted to right. Location changes are not tracked.

@varun.arora

You want to see a list of differences something like:
“table position was changed: old position , new position”.
Currently tracking of changes for the table position is implemented like in the attached screenshot (shared earlier). We could try to improve it but cannot share any ETA at the moment.

Thanks, Is there any incident( COMPARISONNET) opened for it?

Our management is trying to finalize the decision on purchasing the tool so all these points incidents we are tracking to present to upper management which will help them in decision making.

Thanks,
Varun

@varun.arora

COMPARISONNET-2626 is expected to be fixed in API version 21.3.
COMPARISONNET-2629 and COMPARISONNET-2651 are still under investigation. However, they are expected to be fixed in API version 21.4.
COMPARISONNET-2628, this issue is already addressed here.
COMPARISONNET-2652, we already shared progress update here.

The issues you have found earlier (filed as COMPARISONNET-2626) have been fixed in this update. This message was posted using Bugs notification tool by Atir_Tahir

Hello,

Can you please tell us what is the comparison unit of the coordinates or height or width?
ChangeInfo.Box.X

Is it mm or inch or something else?

Thanks,
Varun

@varun.arora

It is pixels. But it also depends on document format. Could you please explicitly define the documents and we’ll assist you accordingly?

TextControl_Template Horizontal Lines.zip (13.7 KB)

This is the document. Can you please let us know what document format we should look at to find the measurable unit?

1 Like

@varun.arora

We’ll investigate the document and let you know about the outcomes.

Hello Atir,

Is there any update on the measurement unit issue?

We are still exploring GroupDocs for the two different sources for comparison if it will work or not.
There are lot more features in 100s of thousand current documents and others generated everyday in which we still need to understand if those can be captured.
But the license is expired and my evidential report to the management for is still incomplete for them to reach to a conclusion for comparing all the upcoming documents and even current documents.
Can you please extend it for 1 more month?

Thanks,
Varun

1 Like

@varun.arora

Like we said that the comparison unit depends on the document format. For this document, it using point(pt) as a unit (1 pt = 1/72 inch).

You can avail one month temporary license here. A temporary license is actually time-restricted full license.

The issues you have found earlier (filed as COMPARISONNET-2651) have been fixed in this update. This message was posted using Bugs notification tool by Atir_Tahir

@varun.arora,

GroupDocs.Comparison for .NET v21.4 that includes fix for this issue has been published. You can find the new version at

Have a nice day!

The issues you have found earlier (filed as COMPARISONNET-2629) have been fixed in this update. This message was posted using Bugs notification tool by anton.samarskyy