GroupDocs.Comparison for Java 19.10 Release Notes

Major Features

Below the list of fixed bugs in this release of GroupDocs.Comparsion for Java. The most notable are:

  • Implemented ability to convert documents of different formats to images
  • Fixed issue with SuperScript and SubScript elements on Words documents
  • Fixed style settings for GroupDocs.Comparison.Html
  • Fixed issue with comparing large sized PDF files (another cases)
  • Fixed not working comparison of EndNote element on Words
  • Implemented calculation of changes for Diagrams, Slides and PDF formats
  • Implemented getting document information method
  • Improved exceptions and error handling all around the projects for all supported formats
  • Fixed issue with getting images for HTML files
  • Fixed issue with Fonts detection
  • Fixed incorrect different in PDF
  • Improved changes detection in tables on Words documents
  • Fixed problem when sections moved to the new page
  • Fixed typos in API reference
  • Implemented sensitivity option
  • Implemented calculation coordinates of changes for Words documents
  • Fixed content overlapping in resultant PDF documents
  • Fixed problem when sections moved to the new page
  • Integrated credit based billing system using latest version of Metered
  • Updated namespace to more logical and convenient  (some some of namespaces were renamed)

Full List of Issues Covering all Changes in this Release

KeySummaryIssue Type
COMPARISONNET-1836Save documents as images for WordsFeature
COMPARISONNET-1837Save documents as images for CellsFeature
COMPARISONNET-1838Save documents as images for SlidesFeature
COMPARISONNET-1839Save documents as images for PDFFeature
COMPARISONNET-1840Save documents as images for HTMLFeature
COMPARISONNET-1841Save documents as images for EmailFeature
COMPARISONNET-1842Save documents as images for NoteFeature
COMPARISONNET-1843Save documents as images for TextFeature
COMPARISONNET-1844Save documents as images for DiagramsFeature
COMPARISONNET-1847Calculate correct coordinates of changes for SlidesFeature
COMPARISONNET-1849 Calculate correct coordinates of changes for PDFFeature
COMPARISONNET-1852 Calculate correct coordinates of changes for DiagramsFeature
COMPARISONNET-1895 Implement Get document info methodFeature
COMPARISONNET-1773 Error handling improvements for all formatsImprovement
COMPARISONNET-1799 Improve change detection in tables on WordsImprovement
COMPARISONNET-1846Calculate correct coordinates of changes for WordsImprovement
COMPARISONNET-1929Implement sensitivity optionImprovement
COMPARISONNET-1901Integrate latest version of Dynabic.Metered into productsImprovement
COMPARISONNET-1815Ignore comments (for code files mostly).Improvement
COMPARISONNET-1816Ignore White Space - All, Leading, Trailing, Changes in amountImprovement
COMPARISONNET-1813Ignore Case - Ignore character case differences.Improvement
COMPARISONNET-1931Refactor GroupDocs.Comparison namespacesImprovement
COMPARISONNET-1806Issue on SuperScript and SubScriptBug
COMPARISONNET-1802Settings StyleSettings is not working for htmlBug
COMPARISONNET-1803Issue in comparing large sized PDF files (another cases)Bug
COMPARISONNET-1804EndNote Comparison is not workingBug
COMPARISONNET-1808 Comparison is not working on FootnoteBug
COMPARISONNET-1772 PDF comparison has overlapping and mangled outputBug
COMPARISONNET-1774 Can’t get images for HTML filesBug
COMPARISONNET-1805 Deleted items in comparison output is not as expectedBug
COMPARISONNET-1892 Incorrect difference info in PDFBug
COMPARISONNET-1899 Html MarkDeletedInsertedContentDeep BugBug
COMPARISONNET-1906 Font detection exceptionBug
COMPARISONNET-1909 Word separation exceptionBug
COMPARISONNET-1927Merged Document and then document Comparison failedBug
COMPARISONNET-1891Text got overlapped with other text or imagesBug
COMPARISONNET-1930Duplicate Images in Result file in PDFBug
COMPARISONNET-1772PDF comparison has overlapping and mangled outputBug
COMPARISONJAVA-374Multithreading comparing returns nullBug

Public API and Backward Incompatible Changes

  1. Extended PageImage properties
    For now PageImage class was extended by adding 2 public properties Width and Height

    Comparer comparer = new Comparer();
    // get the list of pages as images
    List<PageImage> sourceImages = comparer.convertToImages(sourcePath);
    // getting sizes of first page
    int height = sourceImages.get(0).getHeight();
    int width = sourceImages.get(0).getWidth();
    
  2. Getting coordinates of changes

    Getting coordinates of specific changes in Result document is working for Slides, PDF and Diagrams, Word documents.

    To use this feature you should specify in ComparisonSettings CalculateComponentCoordinates property

    ComparisonSetting settings = new ComparisonSetting
    ...
    settings.setCalculateComponentCoordinates(true);
    ...
    

    The coordinates of changes will be stored in  Box property of ChangeInfo class

    Comparer comparer = new Comparer();
    // Settings
    ComparisonSettings comparisonSettings = new ComparisonSettings();
    comparisonSettings.setCalculateComponentCoordinates(true);
    // Compare documents
    ICompareResult compareResult = comparer.compare(sourcePath, targetName, comparisonSettings);
    // Getting sizes of the first change
    ChangeInfo[] changes = compareResult.getChanges();
    // Coordinates of first change
    final Rectangle rectangle = changes[0].getBox();
    

    Example of further using this option:

    ComparisonSettings comparisonSettings = new ComparisonSettings();
    comparisonSettings.setStyleChangeDetection(true);
    //this setting specify that we want to have change coordinates
    comparisonSettings.setCalculateComponentCoordinates(true);
    comparisonSettings.setDetailLevel(DetailLevel.High);
    
    Comparer comparer = new Comparer();
    ICompareResult result = comparer.compare(sourcePath, targetPath, comparisonSettings);
    result.saveDocument(resultPath);
    
    
    List<PageImage> resultImages = comparer.convertToImages(resultPath);
    final ChangeInfo[] changes = result.getChanges();
    
    
    // Below the one of cases how we could use changes coordinates.
    // We are passing through pages object and draw a rectangle in the coordinates of changes
    for (PageImage pageImage : resultImages) {
        final InputStream pageStream = pageImage.getPageStream();
        final BufferedImage bufferedImage = ImageIO.read(pageStream);
        final Graphics graphics = bufferedImage.getGraphics();
        for (ChangeInfo changeInfo : changes) {
            final Rectangle rectangle = changeInfo.getBox();
            //if something was Inserted draw a Blue rectange
            if (changeInfo.getType() == TypeChanged.Inserted) {
                graphics.setColor(Color.BLUE);
                graphics.drawRect((int) rectangle.getX(), (int) rectangle.getY(), (int) rectangle.getWidth(), (int) rectangle.getHeight());
            }
            //if something was Deleted draw a Red rectange
            if (changeInfo.getType() == TypeChanged.Deleted) {
    
                graphics.setColor(Color.RED);
                graphics.drawRect((int) rectangle.getX(), (int) rectangle.getY(), (int) rectangle.getWidth(), (int) rectangle.getHeight());
            }
            //if something was Changes draw a Green rectange
            if (changeInfo.getType() == TypeChanged.StyleChanged) {
                graphics.setColor(Color.GREEN);
                graphics.drawRect((int) rectangle.getX(), (int) rectangle.getY(), (int) rectangle.getWidth(), (int) rectangle.getHeight());
            }
        }
        ImageIO.write(bufferedImage, "png", new File(resultPath.replace("result", "result_" + pageImage.getPageNumber()) + ".png"));
        graphics.dispose();
        pageStream.close();
    }
    
  3. Getting Image representation of document pages

    Comparer comparer = new Comparer();
    ComparisonSettings comparisonSettings = new ComparisonSettings();
    comparisonSettings.setStyleChangeDetection(true);
    
    // Compare document
    ICompareResult result = comparer.compare(sourcePath, targetPath, comparisonSettings);
    result.saveDocument(resultPath);
    
    // Get list of pages
    List<PageImage> resultImages = comparer.convertToImages(resultPath);
    
    // Save them as bitmap to separate folder
    for (PageImage pageImage : resultImages) {
        final InputStream pageStream = pageImage.getPageStream();
    
        Assert.assertNotNull(pageStream);
    
        final BufferedImage bufferedImage = ImageIO.read(pageStream);
        ImageIO.write(bufferedImage, "png", new File(resultPath.replace(resultName, "result_" + pageImage.getPageNumber()) + ".png"));
    }
    
  4. New DocumentInfo class

    New DocumentInfo class was added. This class contains following properties

    NumberOfPages (read only) - the count of document pages
    PagesData (read only) - the list of PageInfo classes,

    PageInfo class contains following properties:
    Width - the width of page
    Height - the height of page

    Informer informer = new Informer();
    // Get information about document from filePath
    DocumentInfo documentInfo = informer.getDocumentInfo(sourcePath);
    
  5. Setting Comparison Detail level

    1. If we set DetailLevel = Middle, we don’t  add comment in some document formats (Words, Slides, Cells) if element was added\deleted\modified
    2. If we set DetailLevel = Middle, we don’t make case insensitive comparison. i.e. M = m.
    3. Was added sensitivity property. This option defined limit in percents, when element is detected as deleted or inserted.

    Minimal value - 0, comparison process not occurs for any length of sequences of two compared objects.

    Value by default - 75, comparison occurs when the percentage of deleted or inserted elements in relation to all elements does not exceed 75%.

    Maximum value - 100, comparison occurs at any length of a common subsequence of two compared objects.

    For instance, we have two words

    1)oneSource
    
    2)twoTarget
    

    This two words have very small a common subsequence.Therefore, when comparing them at 70% accuracy, it is not taken into account and we get a completely removed and inserted word:

    (twoTarget)[oneSource]
    

    But at 100% accuracy, we take into account this subsequence, despite the fact that it consists of two letters

    (tw)o[n](Targ)e[Source](t)
    

    Code snippet:

    ComparisonSettings comparisonSettings = new ComparisonSettings();
    comparisonSettings.setSensitivityOfComparison(100);
    Comparer compare = new Comparer();
    ICompareResult result = compare.compare(sourcePath, targetPath, comparisonSettings);