@@ -410,6 +410,105 @@ public virtual void RemoveAllTheFieldAnnotationsTest() {
410410 }
411411 }
412412
413+ [ NUnit . Framework . Test ]
414+ public virtual void SimpleTaggedDocTest ( ) {
415+ using ( PdfDocument document = new PdfDocument ( new PdfReader ( SOURCE_FOLDER + "simpleTaggedDoc.pdf" ) ) ) {
416+ DocumentRevisionsValidator validator = builder . BuildDocumentRevisionsValidator ( ) ;
417+ ValidationReport report = validator . ValidateAllDocumentRevisions ( validationContext , document ) ;
418+ AssertValidationReport . AssertThat ( report , ( a ) => a . HasStatus ( ValidationReport . ValidationResult . VALID ) . HasNumberOfLogs
419+ ( 0 ) ) ;
420+ }
421+ }
422+
423+ [ NUnit . Framework . Test ]
424+ public virtual void TaggedDocAddAndRemoveAnnotationsTest ( ) {
425+ using ( PdfDocument document = new PdfDocument ( new PdfReader ( SOURCE_FOLDER + "taggedDocAddAndRemoveAnnotations.pdf"
426+ ) ) ) {
427+ DocumentRevisionsValidator validator = builder . BuildDocumentRevisionsValidator ( ) ;
428+ ValidationReport report = validator . ValidateAllDocumentRevisions ( validationContext , document ) ;
429+ // Annotations were removed, but were also considered modified objects and therefore are added to xref table.
430+ AssertValidationReport . AssertThat ( report , ( a ) => a . HasStatus ( ValidationReport . ValidationResult . VALID ) . HasNumberOfLogs
431+ ( 2 ) . HasLogItem ( ( l ) => l . WithCheckName ( DocumentRevisionsValidator . DOC_MDP_CHECK ) . WithMessage ( DocumentRevisionsValidator
432+ . UNEXPECTED_ENTRY_IN_XREF , ( m ) => "18" ) . WithStatus ( ReportItem . ReportItemStatus . INFO ) ) . HasLogItem ( ( l ) =>
433+ l . WithCheckName ( DocumentRevisionsValidator . DOC_MDP_CHECK ) . WithMessage ( DocumentRevisionsValidator . UNEXPECTED_ENTRY_IN_XREF
434+ , ( m ) => "50" ) . WithStatus ( ReportItem . ReportItemStatus . INFO ) ) ) ;
435+ }
436+ }
437+
438+ [ NUnit . Framework . Test ]
439+ public virtual void TaggedDocRemoveStructTreeElementTest ( ) {
440+ using ( PdfDocument document = new PdfDocument ( new PdfReader ( SOURCE_FOLDER + "taggedDocRemoveStructTreeElement.pdf"
441+ ) ) ) {
442+ DocumentRevisionsValidator validator = builder . BuildDocumentRevisionsValidator ( ) ;
443+ ValidationReport report = validator . ValidateAllDocumentRevisions ( validationContext , document ) ;
444+ AssertValidationReport . AssertThat ( report , ( a ) => a . HasStatus ( ValidationReport . ValidationResult . INVALID ) . HasNumberOfFailures
445+ ( 1 ) . HasLogItem ( ( l ) => l . WithCheckName ( DocumentRevisionsValidator . DOC_MDP_CHECK ) . WithMessage ( DocumentRevisionsValidator
446+ . STRUCT_TREE_ROOT_MODIFIED ) . WithStatus ( ReportItem . ReportItemStatus . INVALID ) ) ) ;
447+ }
448+ }
449+
450+ [ NUnit . Framework . Test ]
451+ public virtual void TaggedDocRemoveStructTreeAnnotationTest ( ) {
452+ using ( PdfDocument document = new PdfDocument ( new PdfReader ( SOURCE_FOLDER + "taggedDocRemoveStructTreeAnnotation.pdf"
453+ ) ) ) {
454+ DocumentRevisionsValidator validator = builder . BuildDocumentRevisionsValidator ( ) ;
455+ ValidationReport report = validator . ValidateAllDocumentRevisions ( validationContext , document ) ;
456+ AssertValidationReport . AssertThat ( report , ( a ) => a . HasStatus ( ValidationReport . ValidationResult . INVALID ) . HasNumberOfFailures
457+ ( 1 ) . HasLogItem ( ( l ) => l . WithCheckName ( DocumentRevisionsValidator . DOC_MDP_CHECK ) . WithMessage ( DocumentRevisionsValidator
458+ . STRUCT_TREE_ROOT_MODIFIED ) . WithStatus ( ReportItem . ReportItemStatus . INVALID ) ) ) ;
459+ }
460+ }
461+
462+ [ NUnit . Framework . Test ]
463+ public virtual void TaggedDocModifyAnnotationTest ( ) {
464+ using ( PdfDocument document = new PdfDocument ( new PdfReader ( SOURCE_FOLDER + "taggedDocModifyAnnotation.pdf"
465+ ) ) ) {
466+ DocumentRevisionsValidator validator = builder . BuildDocumentRevisionsValidator ( ) ;
467+ ValidationReport report = validator . ValidateAllDocumentRevisions ( validationContext , document ) ;
468+ AssertValidationReport . AssertThat ( report , ( a ) => a . HasStatus ( ValidationReport . ValidationResult . VALID ) . HasNumberOfLogs
469+ ( 0 ) ) ;
470+ }
471+ }
472+
473+ [ NUnit . Framework . Test ]
474+ public virtual void TaggedDocModifyAnnotationAndStructElementTest ( ) {
475+ using ( PdfDocument document = new PdfDocument ( new PdfReader ( SOURCE_FOLDER + "taggedDocModifyAnnotationAndStructElement.pdf"
476+ ) ) ) {
477+ DocumentRevisionsValidator validator = builder . BuildDocumentRevisionsValidator ( ) ;
478+ ValidationReport report = validator . ValidateAllDocumentRevisions ( validationContext , document ) ;
479+ AssertValidationReport . AssertThat ( report , ( a ) => a . HasStatus ( ValidationReport . ValidationResult . INVALID ) . HasNumberOfFailures
480+ ( 2 ) . HasLogItem ( ( l ) => l . WithCheckName ( DocumentRevisionsValidator . DOC_MDP_CHECK ) . WithMessage ( DocumentRevisionsValidator
481+ . STRUCT_TREE_ROOT_MODIFIED ) . WithStatus ( ReportItem . ReportItemStatus . INVALID ) ) . HasLogItem ( ( l ) => l . WithCheckName
482+ ( DocumentRevisionsValidator . DOC_MDP_CHECK ) . WithMessage ( DocumentRevisionsValidator . STRUCT_TREE_ELEMENT_MODIFIED
483+ ) . WithStatus ( ReportItem . ReportItemStatus . INVALID ) ) ) ;
484+ }
485+ }
486+
487+ [ NUnit . Framework . Test ]
488+ public virtual void TaggedDocModifyAnnotationAndStructContentTest ( ) {
489+ using ( PdfDocument document = new PdfDocument ( new PdfReader ( SOURCE_FOLDER + "taggedDocModifyAnnotationAndStructContent.pdf"
490+ ) ) ) {
491+ DocumentRevisionsValidator validator = builder . BuildDocumentRevisionsValidator ( ) ;
492+ ValidationReport report = validator . ValidateAllDocumentRevisions ( validationContext , document ) ;
493+ AssertValidationReport . AssertThat ( report , ( a ) => a . HasStatus ( ValidationReport . ValidationResult . VALID ) . HasNumberOfLogs
494+ ( 0 ) ) ;
495+ }
496+ }
497+
498+ [ NUnit . Framework . Test ]
499+ public virtual void TaggedDocModifyStructElementTest ( ) {
500+ using ( PdfDocument document = new PdfDocument ( new PdfReader ( SOURCE_FOLDER + "taggedDocModifyStructElement.pdf"
501+ ) ) ) {
502+ DocumentRevisionsValidator validator = builder . BuildDocumentRevisionsValidator ( ) ;
503+ ValidationReport report = validator . ValidateAllDocumentRevisions ( validationContext , document ) ;
504+ AssertValidationReport . AssertThat ( report , ( a ) => a . HasStatus ( ValidationReport . ValidationResult . INVALID ) . HasNumberOfFailures
505+ ( 2 ) . HasLogItem ( ( l ) => l . WithCheckName ( DocumentRevisionsValidator . DOC_MDP_CHECK ) . WithMessage ( DocumentRevisionsValidator
506+ . STRUCT_TREE_ROOT_MODIFIED ) . WithStatus ( ReportItem . ReportItemStatus . INVALID ) ) . HasLogItem ( ( l ) => l . WithCheckName
507+ ( DocumentRevisionsValidator . DOC_MDP_CHECK ) . WithMessage ( DocumentRevisionsValidator . STRUCT_TREE_ELEMENT_MODIFIED
508+ ) . WithStatus ( ReportItem . ReportItemStatus . INVALID ) ) ) ;
509+ }
510+ }
511+
413512 [ NUnit . Framework . Test ]
414513 public virtual void RemoveUnnamedFieldTest ( ) {
415514 using ( PdfDocument document = new PdfDocument ( new PdfReader ( SOURCE_FOLDER + "removeUnnamedField.pdf" ) ) ) {
0 commit comments