@@ -1579,14 +1579,19 @@ private bool CompareObjects(PdfObject outObj, PdfObject cmpObj, CompareTool.Obje
15791579 outPagesRef . Add ( outRefKey . GetDocument ( ) . GetPage ( i ) . GetPdfObject ( ) . GetIndirectReference ( ) ) ;
15801580 }
15811581 }
1582- if ( cmpPagesRef . Contains ( cmpRefKey ) && cmpPagesRef . IndexOf ( cmpRefKey ) == outPagesRef . IndexOf ( outRefKey ) ) {
1583- return true ;
1584- }
1585- if ( compareResult != null && currentPath != null ) {
1586- compareResult . AddError ( currentPath , MessageFormatUtil . Format ( "The dictionaries refer to different pages. Expected page number: {0}. Found: {1}"
1587- , cmpPagesRef . IndexOf ( cmpRefKey ) + 1 , outPagesRef . IndexOf ( outRefKey ) ) + 1 ) ;
1582+ // If at least on of the page dictionaries is in the document's page tree, we don't proceed with deep comparison,
1583+ // because pages are compared at different level, so we compare only their index.
1584+ // However only if both page dictionaries are not in the document's page trees, we continue to comparing them as normal dictionaries.
1585+ if ( cmpPagesRef . Contains ( cmpRefKey ) || outPagesRef . Contains ( outRefKey ) ) {
1586+ if ( cmpPagesRef . Contains ( cmpRefKey ) && cmpPagesRef . IndexOf ( cmpRefKey ) == outPagesRef . IndexOf ( outRefKey ) ) {
1587+ return true ;
1588+ }
1589+ if ( compareResult != null && currentPath != null ) {
1590+ compareResult . AddError ( currentPath , MessageFormatUtil . Format ( "The dictionaries refer to different pages. Expected page number: {0}. Found: {1}"
1591+ , cmpPagesRef . IndexOf ( cmpRefKey ) + 1 , outPagesRef . IndexOf ( outRefKey ) + 1 ) ) ;
1592+ }
1593+ return false ;
15881594 }
1589- return false ;
15901595 }
15911596 if ( cmpDirectObj . IsDictionary ( ) ) {
15921597 if ( ! CompareDictionariesExtended ( ( PdfDictionary ) outDirectObj , ( PdfDictionary ) cmpDirectObj , currentPath , compareResult
0 commit comments