@@ -117,6 +117,7 @@ public class DocumentRevisionsValidator {
117
117
static final String PAGES_MODIFIED = "Pages structure was unexpectedly modified." ;
118
118
static final String PAGE_ANNOTATIONS_MODIFIED = "Page annotations were unexpectedly modified." ;
119
119
static final String PAGE_MODIFIED = "Page was unexpectedly modified." ;
120
+ static final String TABS_MODIFIED = "Tabs entry in a page dictionary was unexpectedly modified." ;
120
121
static final String PERMISSIONS_REMOVED = "Permissions dictionary was removed from the catalog." ;
121
122
static final String PERMISSIONS_TYPE = "Permissions must be a dictionary." ;
122
123
static final String PERMISSION_REMOVED = "Permission \" {0}\" dictionary was removed or unexpectedly modified." ;
@@ -1310,17 +1311,24 @@ private boolean comparePages(PdfDictionary prevPages, PdfDictionary currPages, V
1310
1311
previousPageCopy .remove (PdfName .Annots );
1311
1312
previousPageCopy .remove (PdfName .Parent );
1312
1313
previousPageCopy .remove (PdfName .StructParents );
1314
+ previousPageCopy .remove (PdfName .Tabs );
1313
1315
PdfDictionary currentPageCopy = new PdfDictionary (currentKid );
1314
1316
currentPageCopy .remove (PdfName .Annots );
1315
1317
currentPageCopy .remove (PdfName .Parent );
1316
1318
currentPageCopy .remove (PdfName .StructParents );
1319
+ currentPageCopy .remove (PdfName .Tabs );
1317
1320
if (!comparePdfObjects (previousPageCopy , currentPageCopy , usuallyModifiedObjects ) ||
1318
1321
!compareIndirectReferencesObjNums (previousKid .get (PdfName .Parent ),
1319
1322
currentKid .get (PdfName .Parent ), report , "Page parent" )) {
1320
1323
report .addReportItem (new ReportItem (DOC_MDP_CHECK , PAGE_MODIFIED , ReportItemStatus .INVALID ));
1321
1324
return false ;
1322
1325
}
1323
1326
1327
+ if (!compareTabs (previousKid .getAsName (PdfName .Tabs ), currentKid .getAsName (PdfName .Tabs ))) {
1328
+ report .addReportItem (new ReportItem (DOC_MDP_CHECK , TABS_MODIFIED , ReportItemStatus .INVALID ));
1329
+ return false ;
1330
+ }
1331
+
1324
1332
PdfArray prevNotModifiableAnnots = getAnnotsNotAllowedToBeModified (previousKid );
1325
1333
PdfArray currNotModifiableAnnots = getAnnotsNotAllowedToBeModified (currentKid );
1326
1334
if (!comparePageAnnotations (prevNotModifiableAnnots , currNotModifiableAnnots , report )) {
@@ -1335,6 +1343,13 @@ private boolean comparePages(PdfDictionary prevPages, PdfDictionary currPages, V
1335
1343
return true ;
1336
1344
}
1337
1345
1346
+ private boolean compareTabs (PdfName previousTabs , PdfName currentTabs ) {
1347
+ if (getAccessPermissions () == AccessPermissions .ANNOTATION_MODIFICATION ) {
1348
+ return true ;
1349
+ }
1350
+ return Objects .equals (previousTabs , currentTabs ) || (previousTabs == null && currentTabs .equals (PdfName .S ));
1351
+ }
1352
+
1338
1353
private void collectRemovedAndAddedAnnotations (PdfArray previousAnnotations , PdfArray currentAnnotations ) {
1339
1354
ValidationReport dummyReport = new ValidationReport ();
1340
1355
List <PdfDictionary > prevAnnots = new ArrayList <>();
0 commit comments