All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.redsix.pdfcompare.CompareResultWithExpectedAndActual Maven / Gradle / Ivy

Go to download

A simple Java library to compare two PDF files. Files are rendered and compared pixel by pixel.

There is a newer version: 1.2.3
Show newest version
package de.redsix.pdfcompare;

import java.awt.image.BufferedImage;
import java.util.Map;
import java.util.TreeMap;

/**
 * A CompareResult, that also stores the expected and actual Image and also keeps diffImages in memory for later display.
 */
public class CompareResultWithExpectedAndActual extends CompareResult {

    private final Map expectedImages = new TreeMap<>();
    private final Map actualImages = new TreeMap<>();

    @Override
    public void addPage(final boolean hasDifferences, final boolean hasDifferenceInExclusion, final int pageIndex, final BufferedImage expectedImage,
            final BufferedImage actualImage, final BufferedImage diffImage) {
        super.addPage(hasDifferences, hasDifferenceInExclusion, pageIndex, expectedImage, actualImage, diffImage);
        expectedImages.put(pageIndex, expectedImage);
        actualImages.put(pageIndex, actualImage);
    }

    @Override
    protected boolean keepImages() {
        return true;
    }

    public synchronized BufferedImage getDiffImage(final int page) {
        return diffImages.get(page);
    }

    public BufferedImage getExpectedImage(final int page) {
        return expectedImages.get(page);
    }

    public BufferedImage getActualImage(final int page) {
        return actualImages.get(page);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy