@@ -458,9 +458,38 @@ def _get_ids_image(
458458 ancest = []
459459 lst : List [Union [str , List [str ]]] = []
460460
461+ if PG .ANNOTS in obj :
462+ for annot in cast (DictionaryObject , obj [PG .ANNOTS ]):
463+ if (
464+ "/AP" in cast (DictionaryObject , annot .keys ())
465+ and "/N" in cast (DictionaryObject , annot ["/AP" ].keys ())
466+ and PG .RESOURCES in annot ["/AP" ]["/N" ].get_object ()
467+ and RES .XOBJECT
468+ in cast (DictionaryObject , annot ["/AP" ]["/N" ][PG .RESOURCES ])
469+ and "/FRM"
470+ in cast (
471+ DictionaryObject , annot ["/AP" ]["/N" ][PG .RESOURCES ][RES .XOBJECT ]
472+ )
473+ ):
474+ frame = annot ["/AP" ]["/N" ][PG .RESOURCES ][RES .XOBJECT ]["/FRM" ]
475+
476+ if PG .RESOURCES in frame .get_object () and RES .XOBJECT in cast (
477+ DictionaryObject , frame [PG .RESOURCES ]
478+ ):
479+ x_object = frame [PG .RESOURCES ][RES .XOBJECT ]
480+ for o in x_object :
481+ if x_object [o ][IA .SUBTYPE ] == "/Image" :
482+ if not isinstance (x_object [o ], StreamObject ):
483+ continue
484+ lst .append (
485+ f"{ PG .ANNOTS } /{ annot ['/T' ]} { o } "
486+ if len (ancest ) == 0
487+ else ancest + [o ]
488+ )
489+
461490 if PG .RESOURCES in obj :
462491 if RES .PATTERN in cast (DictionaryObject , obj [PG .RESOURCES ]):
463- for patternName , pattern in cast (
492+ for pattern_name , pattern in cast (
464493 DictionaryObject ,
465494 cast (DictionaryObject , obj [PG .RESOURCES ])[RES .PATTERN ],
466495 ).items ():
@@ -473,7 +502,7 @@ def _get_ids_image(
473502 continue
474503 if x_object [o ][IA .SUBTYPE ] == "/Image" :
475504 lst .append (
476- f"{ RES .PATTERN } { patternName } { o } "
505+ f"{ RES .PATTERN } { pattern_name } { o } "
477506 if len (ancest ) == 0
478507 else ancest + [o ]
479508 )
@@ -522,6 +551,30 @@ def _get_image(
522551 cast (DictionaryObject , patterns [pattern_name ])[PG .RESOURCES ],
523552 )[RES .XOBJECT ],
524553 )
554+ elif isinstance (id , str ) and id .find (PG .ANNOTS ) == 0 :
555+ annot_name = id [len (RES .PATTERN ) : id .find ("/" , len (RES .PATTERN ) + 1 )]
556+ annots = cast (DictionaryObject , obj [PG .ANNOTS ])
557+
558+ for temp_annot in annots :
559+ if temp_annot ["/T" ] == annot_name :
560+ annot = temp_annot
561+ break
562+
563+ frame_xobjs = cast (
564+ DictionaryObject ,
565+ cast (
566+ DictionaryObject ,
567+ cast (DictionaryObject , annot ["/AP" ]["/N" ])[PG .RESOURCES ],
568+ )[RES .XOBJECT ],
569+ )
570+
571+ xobjs = cast (
572+ DictionaryObject ,
573+ cast (
574+ DictionaryObject ,
575+ cast (DictionaryObject , frame_xobjs ["/FRM" ])[PG .RESOURCES ],
576+ )[RES .XOBJECT ],
577+ )
525578 else :
526579 xobjs = cast (
527580 DictionaryObject ,
@@ -541,6 +594,9 @@ def _get_image(
541594 if id .find ("/Pattern" ) == 0 :
542595 image_identifier = id [id .rfind ("/" ) :]
543596 image_name = pattern_name [1 :] + "_" + image_identifier [1 :]
597+ elif id .find ("/Annot" ) == 0 :
598+ image_identifier = id [id .rfind ("/" ) :]
599+ image_name = annot_name + "_" + image_identifier [1 :]
544600 else :
545601 image_identifier = str (id )
546602 image_name = id [1 :]
0 commit comments