How to get the differences per page for two PDFs

To get the differences per page for two PDF files, start the comparison and assign the result to a local variable and the initialization one integer array for the result.

ResultModel result = new PDFComparer().compare( <file1>, <file2> );
int[] changePerPage = new int[result.getMaxPageCount()];

Then get all differences

List<DiffGroup> differences = result.getDifferences( false );

For each DiffGroup get the Modification and for each Modification get all affected elements. ! The list of modification can be null !
After them iterate over the PagedElement and add it to the result array.

List<PagedElement> affectedElements = modification.getAffectedElements( true );
for( PagedElement affectedElement : affectedElements ) {
    int pageIndex = affectedElement.getPageIndex();
    changePerPage[pageIndex] += 1;
}

View full sourcecode