Disable image comparison in PDF documents

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Comparison MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

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