Disable image comparison in PDF documents

On this page


GroupDocs.Comparison allows you to disable image comparison in PDF documents.

By default, the CompareImagesPdf option is true. Follow these steps to turn off image comparison:

  1. Instantiate the Comparer object. Specify the source file path or stream.
  2. Call the add() method. Specify the target file path or stream.
  3. Instantiate the PdfCompareOptions object. Call setCompareImagesPdf(false).
  4. Call setImagesInheritanceMode() with ImagesInheritance.SOURCE or ImagesInheritance.TARGET to choose which document the images in the result are taken from. The default is SOURCE.
  5. Call the compare() method. Specify the PdfCompareOptions object from the previous steps.

The following code snippet shows how to disable image comparison in PDF documents:

import com.groupdocs.comparison.Comparer;
import com.groupdocs.comparison.options.PdfCompareOptions;
import com.groupdocs.comparison.options.enums.ImagesInheritance;
// ...

try (Comparer comparer = new Comparer("source.pdf")) {
    comparer.add("target.pdf");

    PdfCompareOptions compareOptions = new PdfCompareOptions();
    compareOptions.setCompareImagesPdf(false);
    compareOptions.setImagesInheritanceMode(ImagesInheritance.TARGET);

    comparer.compare("result.pdf", compareOptions);
}

The result is as follows:

Note
CompareOptions.setCompareImagesPdf() and CompareOptions.setImagesInheritanceMode() are still available for backward compatibility, but they are deprecated. Use PdfCompareOptions in new code.

See also

On this page

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.