# How to get the differences per page for two PDFs

**URL:** <https://faq.inetsoftware.de/t/how-to-get-the-differences-per-page-for-two-pdfs/51>\
**Category:** API\
**Tags:** version4, version3\
**Created:** [June 7, 2016, 9:45am UTC](https://faq.inetsoftware.de/t/how-to-get-the-differences-per-page-for-two-pdfs/51 "2016-06-07T09:45:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RichardRoedel](https://faq.inetsoftware.de/user_avatar/faq.inetsoftware.de/richardroedel/32/27_2.png) [@RichardRoedel](https://faq.inetsoftware.de/u/RichardRoedel)\
**Post date:** [June 7, 2016, 9:45am UTC](https://faq.inetsoftware.de/t/how-to-get-the-differences-per-page-for-two-pdfs/51/1 "2016-06-07T09:45:37Z")

</div>

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](https://github.com/i-net-software/pdfc-samples/blob/master/src/main/java/differences/NumOfDifferencePerPage.java)
