GroupDocs.Comparison for Java 17.3.0 Release Notes

Major Features

There are improvements and fixes in this regular monthly release. The most notable are:

  • Introduced support of Shapes in Comparison.Cells
  • Introduced support of text watermarks in Comparison.PDF
  • Improved aligning of slides for more precise changes detection in GroupDocs.Comparison.Slides
  • Improved GroupDocs.Comparison.PDF object model and comparison efficiency
  • Introduced support of support for Apply/Discard changes in Comparison.Cells
  • Introduced support of support for Apply/Discard changes in Comparison.PDF
  • Introduced support of support for Watermarks, Hyperlinks, Comments, Text Box, Shapes in Comparison.Cells
  • Improved GroupDocs.Comparison.PDF comparison efficiency
  • Add support of Imaging DjVu
  • Introduced support of support for Text Font in Watermark in Comparison.PDF
  • Introduced support of support for Images, Charts,  Smart Art, VBA Controls, Formulas in Comparison.Cells
  • Improved GroupDocs.Comparison.PDF comparison efficiency
  • Add ability of comparing DICOM documents by Comparison.Imaging
  • Simplified and improved public API across all supported formats
  • Introduced the process absorbing of tables with merged cells for GroupDocs.Comparison.PDF
  • Fixed comparing filled tables for GroupDocs.Comparison.PDF

Full List of Issues Covering all Changes in this Release

KeySummaryCategory
COMPARISONNET-1034GroupDocs.Comparison.Cells: add support for ShapesNew Feature
COMPARISONNET-1011GroupDocs.Comparison.PDF: add support of styles to text watermarksNew Feature
COMPARISONNET-1053GroupDocs.Comparison.PDF: Add support for Apply/Discard changesNew Feature
COMPARISONNET-975GroupDocs.Comparison.PDF: Add support for WatermarksNew Feature
COMPARISONNET-1065GroupDocs.Comparison.Cells: Add support for HyperlinksNew Feature
COMPARISONNET-1069GroupDocs.Comparison.Cells: Add support for CommentsNew Feature
COMPARISONNET-1072GroupDocs.Comparison.Cells: Add support for Text BoxNew Feature
COMPARISONNET-1063GroupDocs.Comparison.Cells: Add support of Apply/Discard changesNew Feature
COMPARISONNET-1073GroupDocs.Comparison.Cells: Add support for ShapesNew Feature
COMPARISONNET-1123Integrate Metered licensingNew Feature
COMPARISONNET-1122GroupDocs.Comparison.PDF: Add support of comparing Text Font in WatermarksNew Feature
COMPARISONNET-1068GroupDocs.Comparison.Cells: Add support for FormulasNew Feature
COMPARISONNET-1065GroupDocs.Comparison.Cells: Add support for ImagesNew Feature
COMPARISONNET-1070GroupDocs.Comparison.Cells: Add support for ChartNew Feature
COMPARISONNET-1066GroupDocs.Comparison.Cells: Add support for Smart ArtNew Feature
COMPARISONNET-1067GroupDocs.Comparison.Cells: Add support for VBA ControlsNew Feature
COMPARISONNET-1108Add support of mobi formatNew Feature
COMPARISONNET-1156Add ability of comparing DICOM documents by Comparison.ImagingNew Feature
COMPARISONNET-1163Apply/Discard changes for DICOM formatNew Feature
OMPARISONNET-1165Add summary page to images streamsNew Feature
COMPARISONNET-1014GroupDocs.Comparison.Slides: Improve aligning of slides for more precise changes detectionImprovement
COMPARISONNET-1029GroupDocs.Comparison.PDF: Remove Text Artifacts from documents before Paragraph absorbationImprovement
COMPARISONNET-1048GroupDocs.Comparison.PDF: Improve set coordinates for componentsImprovement
COMPARISONNET-1047GroupDocs.Comparison.PDF: Improve set HorizontalAlignmentImprovement
COMPARISONNET-1075GroupDocs.Comparison.Cells: Add borders for deleted and inserted cells and Range of cellsImprovement
COMPARISONNET-679Fix problem when moving modified table into new page and not deleting previous version of added tableImprovement
COMPARISONNET-1055Improve Trim paragraphs by pages after some change in absorbing paragraphsImprovement
COMPARISONNET-1080GroupDocs.Comparison.PDF: Improve comparison changes detection for ParagraphsImprovement
COMPARISONNET-1056Improve GroupDocs.Comparison.PDF comparison quality for images in header, footer, setting coordinates for components and paragraphs by pagesImprovement
COMPARISONNET-1112Add support of Imaging DjVuImprovement
COMPARISONNET-1080GroupDocs.Comparison.PDF: Improve comparison changes detection for ParagraphsImprovement
COMPARISONNET-778Implement the process absorbing of tables with merged cellsImprovement
COMPARISONNET-1148Improved public APIImprovement
COMPARISONNET-1161Add ability for comparison of result and original files in Imaging.TestsImprovement
COMPARISONNET-1157Add localize exceptions for wrong passwords while opening documents in Cells, Words, Slides and PDFImprovement
COMPARISONNET-953Compile Error on Comparison Document for VB.NETBug
COMPARISONNET-946Exception: The newChild was created from a different document than the one that created this node.Bug
COMPARISONNET-1074GroupDocs.Comparison: PDF: Set type change for paragraph runs after page breakBug
COMPARISONNET-1077Comparison.Cells: Fix cells appearance after critical update for Aligner comparer and Document builderBug
COMPARISONNET-1129GroupDocs.Comparison.PDF: Fix bug when some lines are deleted or inserted where should not beBug
COMPARISONNET-1130GroupDocs.Comparison.PDF: Fix bug when first line of paragraph don’t have indent but should haveBug
COMPARISONNET-1131GroupDocs.Comparison.PDF: Fix bug when component change its page but dont change its position but should beBug
COMPARISONNET-1128GroupDocs.Comparison.PDF: Fix bug when first line of paragraph use as not paragraph lineBug
COMPARISONNET-1132GroupDocs.Comparison.PDF: Fix bug when text from tables use twice with simple paragraphsBug
COMPARISONNET-1160PDF Comparison - PDF files with tables and footer lines generating unexpected outputBug

Public API and Backward Incompatible Changes

Updated way to use Comparison Settings for following derived objects:

  • WordsComparisonSettings
  • PdfComparisonSettings
  • CellsComparisonSettings
  • SlidesComparisonSettings
  • TextComparisonSettings

Properties

NameDescription
ShowDeletedContentShows or Hides deleted content of comparison
GenerateSummaryPageEnables or Disables an ability to generate summary page for result document
StyleChangeDetectionGets or Sets an ability to detect style changes for documents subcomponents
MovedContentDetectionGets or Sets an ability to detect content movement
InsertedItemsStyleGets or Sets style for inserted components
StyleChangedItemsStyleGets or sets style for component that changed style
DeletedItemsStyleGets or Sets style for deleted components
WordsSeparatorCharsGets or Sets a list of chars thatparses text content into text fragmentwhile comparison
ComparisonDepthGets or Sets the depth of comparison(chars or text fragments)
ExceptionSilentModeGets or Sets silent mode for an application
ComparerSplitterGets or Sets a Regex Splitter that parses text content into text fragment while comparison

Style Setting

NameDescription
ChartImageGets or Sets a value, save Charts as image.

Word Comparison Settings

Properties

NameDescription
ProcessHyperLinksAsATextGets or Sets a value indicating whether hyperlinks proceeded as a text

Working with settings

To start working with settings for Comparison, you have to create a new instance of ComparisonSettings for necessary file format. For example

CellsComparisonSettings settings = new CellsComparisonSettings()

//Or

WordsComparisonSettings settings = new WordsComparisonSettings()

You can create a ComparisonSettings object for every comparison type which is supported by GroupDocs.Comparison library

After creating a new instance of ComparisonSettings you are able to change settings properties. For example:

settings.setShowDeletedContent(false);
settings.setGenerateSummaryPage(true);

User is able to change also parameters that is specific for certain format. For example:

WordsComparisonSettings settings = new WordsComparisonSettings()
settings.setProcessHyperLinksAsAText(true);

Updated Open Document API to work with .opt format

Open words document from InputStream

NOTE: Assuming there are files in source.docx, source.xlsx, source.pdf, source.pptx, source.txt are in the resource folder.

// Enter document path
String sourcePath = "./source.docx";

// Create stream of document
FileInputStream sourceStream = new FileInputStream(sourcePath);

// Open ComparisonDocument.
ComparisonDocument document = new ComparisonDocument(sourceStream);
 

Open words document from file

// Enter document path
String sourcePath = "./source.docx";

// Open ComparisonDocument.
ComparisonDocument document = new ComparisonDocument(sourcePath);

**Open **workbook****

Open workbook from InputStream

// Enter workbook path
String sourcePath = "./source.xlsx";

// Create stream of workbook
FileInputStream sourceStream = new FileInputStream(sourcePath);

// Open ComparisonWorkbook.
ComparisonWorkbook workbook = new ComparisonWorkbook(sourceStream);

Open workbook from file

// Enter workbook path
String sourcePath = "./source.xlsx";

// Open ComparisonWorkbook.
ComparisonWorkbook workbook = new ComparisonWorkbook(sourcePath);

**Open **PDF document****

Open PDF document from InputStream

// Enter document path
String sourcePath = "./source.pdf";

// Create stream of document
FileInputStream sourceStream = new FileInputStream(sourcePath);

// Open ComparisonDocument.
ComparisonPdfDocument document = new ComparisonPdfDocument(sourceStream);

Open PDF document from file 

// Enter document path
String sourcePath = "./source.pdf";

// Open ComparisonDocument.
ComparisonPdfDocument document = new ComparisonPdfDocument(sourcePath);

**Open **Presentation****

Open presentation from InputStream

// Enter presentation path
String sourcePath = "./source.pptx";

// Create stream of presentation
FileInputStream sourceStream = new FileInputStream(sourcePath);

// Open ComparisonPresentation.
ComparisonPresentation presentation = new ComparisonPresentation(sourceStream);

Open presentation from file

// Enter presentation path
String sourcePath = "./source.pptx";

// Open ComparisonPresentation.
ComparisonPresentation presentation = new ComparisonPresentation(sourcePath);

**Open **Text file****

Open text file from InputStream

// Enter textFile path
String sourcePath = "./source.txt";

// Create stream of document
FileInputStream sourceStream = new FileInputStream(sourcePath);

// Open ComparisonTextFile.
ComparisonTextFile textFile = new ComparisonTextFile(sourceStream);

Open text file from file 

// Enter document path
String sourcePath = "./source.txt";

// Open ComparisonTextFile.
ComparisonTextFile textFile = new ComparisonTextFile(sourcePath);
 

**Open HTML **file****

Open HTML  file from InputStream

// Enter document path
String sourcePath = "./source.html";
InputStream sourceStream = this.getClass().getClassLoader().getResourceAsStream(sourcePath);

// Open ComparisonTextFile.
IComprisonHtmlDocument htmlFile = new ComparisonHtmlDocument(sourceStream);

Open HTML file from file 

// Enter document path
String sourcePath = "./source.html";

// Open ComparisonTextFile.
IComparisonHtmlDocument htmlFile = new ComparisonHtmlDocument(sourcePath);

Updated Presentation API to work with .opt format

Compare two presentations from streams with saving to file and settings

NOTE: Assuming there are files in source.docx, source.xlsx, source.pdf, source.pptx, source.txt are in the resources folder of samples.

// Enter presentations paths
String sourcePath = "./source.pptx";
String targetPath = "./target.pptx";
String resultPath = "./result.pptx";

// Create stream of document
InputStream sourceStream = new FileInputStream(sourcePath);
InputStream targetStream = new FileInputStream(targetPath);

// Create instance of *GroupDocs.Comparison.Comparison* and call method *Compare*.
Comparison comparison = new Comparison();
InputStream result = comparison.compare(sourceStream, targetStream, resultPath, ComparisonType.Slides, new SlidesComparisonSettings());

 Compare two presentations from streams with settings

// Enter presentations paths
String sourcePath = "./source.pptx";
String targetPath = "./target.pptx";

// Create two streams of presentations

InputStream sourceStream = new FileInputStream(sourcePath);
InputStream targetStream = new FileInputStream(targetPath);

// Create instance of *GroupDocs.Comparison.Comparison* and call method *Compare*.
Comparison comparison = new Comparison();
InputStream result = comparison.compare(sourceStream, targetStream, ComparisonType.Slides, new SlidesComparisonSettings());

 Compare two presentations from streams with saving to file

// Enter presentations paths
String sourcePath = "./source.pptx";
String targetPath = "./target.pptx";
String resultPath = "./result.pptx";

// Create two streams of presentations
InputStream sourceStream = new FileInputStream(sourcePath);
InputStream targetStream = new FileInputStream(targetPath);

// Create instance of *GroupDocs.Comparison.Comparison* and call method *Compare*.
Comparison comparison = new Comparison();
InputStream result = comparison.compare(sourceStream, targetStream, resultPath, ComparisonType.Slides);

Compare two presentations from streams

// Enter presentations paths
String sourcePath = "./source.pptx";
String targetPath = "./target.pptx";

// Create two streams of presentations
InputStream sourceStream = new FileInputStream(sourcePath);
InputStream targetStream = new FileInputStream(targetPath);

// Create instance of *GroupDocs.Comparison.Comparison* and call method *Compare*.
Comparison comparison = new Comparison();
InputStream result = comparison.compare(sourceStream, targetStream, ComparisonType.Slides);

Compare two presentations from files with saving to file and settings

// Enter presentations paths
String sourcePath = "./source.pptx";
String targetPath = "./target.pptx";
String resultPath = "./result.pptx";

// Create instance of *GroupDocs.Comparison.Comparison* and call method *Compare*.
Comparison comparison = new Comparison();
InputStream result = comparison.compare(sourcePath, targetPath, resultPath, ComparisonType.Slides, new SlidesComparisonSettings());

Compare two presentations from files with settings

// Enter presentations paths
String sourcePath = "./source.pptx";
String targetPath = "./target.pptx";

// Create instance of *GroupDocs.Comparison.Comparison* and call method *Compare*.
Comparison comparison = new Comparison();
InputStream result = comparison.compare(sourcePath, targetPath, ComparisonType.Slides, new SlidesComparisonSettings());

 Compare two presentations from files with saving to file

// Enter presentations paths
String sourcePath = "./source.pptx";
String targetPath = "./target.pptx";
String resultPath = "./result.pptx";

// Create instance of *GroupDocs.Comparison.Comparison* and call method *Compare*.
Comparison comparison = new Comparison();
InputStream result = comparison.compare(sourcePath, targetPath, resultPath, ComparisonType.Slides);

Compare two presentations from files

// Enter presentations paths
String sourcePath = "./source.pptx";
String targetPath = "./target.pptx";

// Create instance of *GroupDocs.Comparison.Comparison* and call method *Compare*.
Comparison comparison = new Comparison();
InputStream result = comparison.compare(sourcePath, targetPath, ComparisonType.Slides);

Updated Save presentation as image API to work with .opt format

Save presentation as image

To start working with image saving for Slides component you have to add GroupDocs.Comparison library and add following imports to your code

import com.groupdocs.comparison.slides.*;
import com.groupdocs.comparison.slides.contracts.*;
import com.groupdocs.comparison.slides.contracts.comparison.*;
import com.groupdocs.comparison.slides.contracts.enums.*;
import com.groupdocs.comparison.common.images.*;

After that you have to specify a path to document which you want to save as image. The easiest way to do it just put the document to output folder of your working project

Save presentation to image via image folder

saveAsImages(String imagePath, ComparsionSlidesImageSettings settings)

ParameterDescription
String imagePathPath to folder where save images
ComparsionSlidesImageSettings settingsImage save settings
//path to file
String filePath = "./presentation.xlsx";

//path to image folder
String imageFolderPath = "./FolderForImage/";

//Open  document
ComparisonPresentationBase presentation = new ComparisonPresentation(filePath);

//Set settings
ComparisonSlidesImageSettings settings = new ComparisonSlidesImageSettings();

//Save as Image
presentation.saveAsImages(imageFolderPath, settings);

Save presentation to image via stream

saveAsImages(ArrayList imageStream, ComparsionSlidesImageSettings settings)

NameDescription
ArrayList imageStreamThe images streams – where each stream from list contains a single page from document
ComparsionSlidesImageSettings settingsImage save settings
//path to file
String filePath = "./presentation.xlsx";

//stream
ArrayList<ByteArrayOutputStream> imageStream = new ArrayList<ByteArrayOutputStream>();

//Open  document
ComparisonPresentationBase presentation = new ComparisonPresentation(filePath);

//Set settings
ComparisonSlidesImageSettings settings = new ComparisonSlidesImageSettings();

//Save as Image
presentation.saveAsImages(imageStream, settings);

Save slide from presentation to image via image folder

saveSlideAsImage (String imagePath, ComparsionSlidesImageSettings settings, int slideIndex )

NameDescription
String imagePathPath to folder where save images
ComparsionSlidesImageSettings settingsImage save settings
int slideIndexIndex of slide
//path to file
String filePath = "./presentation.xlsx";

//path to image folder
String imageFolderPath = "./FolderForImage/";

//Open  document
ComparisonPresentationBase presentation = new ComparisonPresentation(filePath);

//Set settings
ComparisonSlidesImageSettings settings = new ComparisonSlidesImageSettings();

//Save slide as Image
presentation.saveSlideAsImage(imageFolderPath, settings, slideIndex);

Save slide of presentation to image via stream

saveSlideAsImage (ArrayList imageStream, ComparsionSlidesImageSettings settings, int slideIndex )

NameDescription
ArrayList imageStreamThe images streams – where each stream from list contains a single page from document
ComparsionSlidesImageSettings settingsImage save settings
int slideIndexIndex of slide
//path to file
String filePath = "./presentation.xlsx";

//Stream
ArrayList<ByteArrayOutputStream> imageStream = new ArrayList<ByteArrayOutputStream>();

//Open  document
ComparisonPresentationBase presentation = new ComparisonPresentation(filePath);

//Set settings
ComparisonSlidesImageSettings settings = new ComparisonSlidesImageSettings();

//Save slide as Image
presentation.saveSlideAsImage(imageStream, settings, slideIndex);

Metered licensing

// Create new instance of GroupDocs.Comparison.Metered classs
Metered metered = new Metered();

// Set public and private key to metered instance
metered.setMeteredKey("***", "***");

// Get metered value before usage of the comparison
BigDecimal amountBefore = Metered.getConsumptionQuantity();

System.out.println("Amount consumed  before: " + amountBefore);

// compare files
String sourcePath = "./data/source.docx";
String targetPath = "./data/target.docx";

Comparison comparison = new Comparison();
InputStream result = comparison.compare(sourcePath, targetPath);

// Get metered value after usage of the comparison
BigDecimal amountAfter = Metered.getConsumptionQuantity();

System.out.println("Amount consumed  after: " + amountAfter);

Extended Public API to support Imaging formats

Compare From Stream

Compare two Imaging(DjVu) Documents from streams with saving results into a file

// Create two streams of documents
InputStream sourceStream = new FileInputStream(sourcePath);
InputStream targetStream = new FileInputStream(targetPath);

ComparisonDjvuImage sourceImage = new ComparisonDjvuImage(sourceStream);
ComparisonDjvuImage targetImage = new ComparisonDjvuImage(targetStream);

ImagingComparisonSettings settings = new ImagingComparisonSettings();

//Compare
IImageCompareResult cr = sourceImage.compareWith(targetImage, settings);
IPdfDocument resultPdf = cr.getPdfDocument();

//save results into a file
resultPdf.save(resultPath);
sourceStream.close();
targetStream.close();

Compare From File

Compare two Imaging(DjVu) Documents from file path with saving results into a file

//Open files
ComparisonDjvuImage sourceImage = new ComparisonDjvuImage(sourcePath);
ComparisonDjvuImage targetImage = new ComparisonDjvuImage(targetPath);
ImagingComparisonSettings settings = new ImagingComparisonSettings();

//Compare
IImageCompareResult cr = sourceImage.compareWith(targetImage, settings);
IPdfDocument resultPdf = cr.getPdfDocument();

//save results into a file
resultPdf.save(resultPath);

Compare From File with document settings

Compare two Imaging(DjVu) Documents from File with saving results into a file with document settings

//Open files
ComparisonDjvuImage sourceImage = new ComparisonDjvuImage(sourcePath);
ComparisonDjvuImage targetImage = new ComparisonDjvuImage(targetPath);

//Create instance of setting
ImagingComparisonSettings settings = new ImagingComparisonSettings();

//Accuracy by X coordinate
settings.setAccuracyX(200);

//Accuracy by Y coordinate
settings.setAccuracyY(200);

//filling density color changed objects
settings.setSaprayFulness(10);

//Fill color for rectangles
settings.setRectangleColor(Color.RED);

//Compare
IImageCompareResult cr = sourceImage.compareWith(targetImage,settings);
IPdfDocument resultPdf = cr.getPdfDocument();

//save results into a file
resultPdf.save(resultPath);