How to get the differences per page for two PDFs

Tags: #<Tag:0x00007f70bf79add8> #<Tag:0x00007f70bf79ac20>

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

© Copyright 1996 - 2018, i-net software; All Rights Reserved.