ó
    /j-jn  ã                   ól  • S r SSKrSSKrSSKrSSKrSSKJr  SSKJrJ	r	J
r
JrJrJrJrJrJrJrJrJrJr  SSKJrJrJrJrJrJrJr  SSKJr  SSKJ r J!r!  SSK"J#r#J$r$J%r%J&r&  SS	K'J(r(J)r)J*r*J+r+J,r,J-r-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5J6r6  SS
K7J8r8J9r9  SSK:J;r;J<r<J=r=J>r>J?r?  SSK@JArAJBrBJCrCJDrDJErE  \(       a  SSKFJGrG  SSKHJIrI  \R”                  " \K5      rL\S   rM\" S\S9rN\*" S5      \*" S5      \*" S5      \*" S5      \*" S5      \*" S5      \*" S5      \*" S5      \*" S5      \*" S5      \*" S5      \*" S5      \*" S5      \*" S5      \*" S 5      \*" S!5      \*" S"5      \*" S#5      \*" S$5      \*" S%5      \*" S&5      \*" S'5      \*" S(5      \*" S)5      \*" S*5      1rO " S+ S,\\   5      rPS-\.S.\.S/\/S0\Q4S1 jrR\ " S2 S35      5       rSg)4z2
Classes for looking at pages and their contents.
é    N)Ú	dataclass)ÚTYPE_CHECKINGÚ
CollectionÚDictÚIterableÚIteratorÚListÚLiteralÚMappingÚTupleÚTypeÚTypeVarÚUnionÚoverload)ÚContentObjectÚGlyphObjectÚImageObjectÚ
PathObjectÚ
TextObjectÚXObjectObjectÚContentSequence)ÚPDFSyntaxError)ÚLazyInterpreterÚFontMapping)ÚContentParserÚLexerÚ	PDFObjectÚToken)ÚMATRIX_IDENTITYÚContentStreamÚKWDÚMatrixÚ	PSLiteralÚ	PSKeywordÚPointÚRectÚ
dict_valueÚ	int_valueÚliteral_nameÚ	num_valueÚ
rect_valueÚresolve1Ústream_value)ÚElementÚPageStructure)Údecode_textÚmult_matrixÚnormalize_rectÚintersect_rectsÚtransform_bbox)ÚPageRefÚ_deref_documentÚ_deref_pageÚ_ref_documentÚ	_ref_page)ÚDocument)ÚFont)ÚpageÚscreenÚdefaultÚuserÚCO)Úbounds   Dos   BMCs   BDCs   EMCó   qó   Qs   cms   gss   BTs   ETs   TJs   Tjó   'ó   "s   Tcs   Tws   Tzs   TLs   Tfs   Trs   Tss   Tds   TDs   Tms   T*c                   ól  • \ rS rSr% SrSr\\S4   \S'   Sr	\\
S4   \S'   Sr\\\S4   S4   \S'   Sr\\\\      S4   \S'     S>S	S
S\S\S\\S4   S\S\SS4S jjrS\S\S\4S jr\S\S   4S j5       r\S?S j5       r\S\\   4S j5       r\S\4S j5       r\S\4S j5       r\S\\   4S j5       r S\S   4S jr!  S@S\\"\#\$      S4   S\\"\%   S4   S\\$   4S jjr&\S\S    4S! j5       r'\S\S"   4S# j5       r(\S\S$   4S% j5       r)\S\S&   4S' j5       r*\S\S(   4S) j5       r+\S\\,   4S* j5       r-\S\\S4   4S+ j5       r.\S\4S, j5       r/\S\
4S- j5       r0\S\\S4   4S. j5       r1S\4S/ jr2\3S\S   4S0 j5       r4\3S1\#\5   S\\5   4S2 j5       r4\3S1\#\5   S\"\%   S\\5   4S3 j5       r4  S@S1\S\#\5   4   S\\"\%   S4   S\\\5S4      4S4 jjr4SS5.S6\\6S4   S\4S7 jjr7SS5.S6\\6S4   S\4S8 jjr8S9\\9S4   S:\\:S4   S\;4S; jr<SS5.S6\\6S4   S\4S< jjr=S=r>g)AÚPageég   ah  An object that holds the information about a page.

Args:
  doc: a Document object.
  pageid: the integer PDF object ID associated with the page in the page tree.
  attrs: a dictionary of page attributes.
  label: page label string.
  page_idx: 0-based index of the page in the document.
  space: the device space to use for interpreting content

Attributes:
  pageid: the integer object ID associated with the page in the page tree
  attrs: a dictionary of page attributes.
  resources: a dictionary of resources used by the page.
  mediabox: the physical size of the page.
  cropbox: the crop rectangle of the page.
  rotate: the page rotation (in degree).
  label: the page's label (typically, the logical page number).
  page_idx: 0-based index of the page in the document.
  ctm: coordinate transformation matrix from default user space to
       page's device space
NÚ
_structmapÚ_marked_contentsr;   Ú_fontmapÚ_textmapÚdocr:   ÚpageidÚattrsÚlabelÚpage_idxÚspaceÚreturnc                 óÎ  • [        U5      U l        X l        X0l        X@l        XPl        X`l        [        U 5      U l        [        U R                  R                  S5      5      U l         [        U R                  R                  S5      5      U l         [#        [%        U R                  S   5      5      U l        U R&                  U l        SU R                  ;   a'   [#        [%        U R                  S   5      5      U l        [1        [3        U R                  R                  S
S5      5      5      nU R5                  Xg5        [        U R                  R                  S5      5      nUc  / U l        g [9        U[:        5      (       a  X€l        g U/U l        g ! [         a!    [        R!                  SU5        0 U l         GN,f = f! [(         a!    [        R!                  SU5        SU l         GN3[*        [,        4 a/    [        R!                  SU R                  S   U5        SU l         GNpf = f! [*        [,        4 a'    [        R!                  S	U R                  S   5         GNbf = f)NÚLastModifiedÚ	Resourcesz,Resources missing or invalid from Page id %dÚMediaBoxzWMediaBox missing from Page id %d (and not inherited), defaulting to US Letter (612x792))r   r   id  i  zDMediaBox %r invalid in Page id %d, defaulting to US Letter (612x792)ÚCropBoxz3Invalid CropBox %r in /Page, defaulting to MediaBoxÚRotater   ÚContents)r8   ÚdocrefrN   rO   rP   rQ   rR   r9   Úpagerefr,   ÚgetÚlastmodr'   Ú	resourcesÚ	TypeErrorÚlogÚwarningr2   r+   ÚmediaboxÚKeyErrorÚ
ValueErrorr   ÚcropboxÚintr*   Úset_initial_ctmÚ	_contentsÚ
isinstanceÚlist)	ÚselfrM   rN   rO   rP   rQ   rR   ÚrotateÚcontentss	            ÚG/home/mande/repo/quber/.venv/lib/python3.13/site-packages/playa/page.pyÚ__init__ÚPage.__init__„   së  € ô $ CÓ(ˆŒØŒØŒ
ØŒ
Ø ŒØŒ
Ü  “ˆŒÜ §
¡
§¡¨~Ó >Ó?ˆŒð	 Ü3=Ø—
‘
—‘˜{Ó+ó4ˆDŒNð	-Ü*¬:°d·j±jÀÑ6LÓ+MÓNˆDŒMð —}‘}ˆŒØ˜Ÿ
™
Ó"ðÜ-¬j¸¿¹ÀIÑ9NÓ.OÓP�”ô ”Y˜tŸz™zŸ~™~¨h¸Ó:Ó;Ó<ˆØ×Ñ˜UÔ+ä˜DŸJ™JŸN™N¨:Ó6Ó7ˆØÑØˆD�Nä˜(¤D×)Ñ)Ø!)•à"* �•øôQ ó 	 Ü�K‰KÐFÈÔOØˆD�Nð	 ûô
 ó 	-Ü�K‰Kð5àôð
 -ˆD�MÜœNÐ+ó 	-Ü�K‰KØVØ—
‘
˜:Ñ&Øôð
 -ˆD�Mð	-ûô ¤Ð/ó Ü—‘ØIØ—J‘J˜yÑ)÷ðús<   Á))F Â&G Ã&H- Æ'F?Æ>F?Ç'H*Ç,:H*È)H*È-3I$É#I$rm   c           	      ó„  • US-   S-  nU R                   u  p4pVXS-
  nXd-
  n[        U l        US:X  a  SSSSSU4U l        OCUS:X  a  SSSSXx4U l        O0US:X  a  SSSSUS4U l        OUS:w  a  [        R	                  SU5        [        U R                  U R                   5      u  p4pVXS-
  nXd-
  nUS	:X  a#  [        U R                  SSSSU* U45      U l        OTUS
:X  a$  [        U R                  SSSSU* U* 45      U l        O*US:w  a  [        R	                  SU5        [        U l        S=pxXl        X l        U R                  $ )aó  
Set or update initial coordinate transform matrix.

PDF 1.7 section 8.4.1: Initial value: a matrix that
transforms default user coordinates to device coordinates.

We keep this as `self.ctm` in order to transform layout
attributes in tagged PDFs which are specified in default
user space (PDF 1.7 section 14.8.5.4.3, table 344)

If you wish to modify the rotation or the device space of the
page, then you can do it with this method (the initial values
are in the `rotate` and `space` properties).
ih  éZ   r   éÿÿÿÿé   é´   i  z9Invalid rotation value %r (only multiples of 90 accepted)r=   r<   r>   zUnknown device space: %r)	rc   r   Úctmra   rb   r4   r1   rR   rm   )	rl   rR   rm   Úx0Úy0Úx1Úy1ÚwidthÚheights	            ro   rh   ÚPage.set_initial_ctmÃ   sX  € ð  ˜3‘, #Ñ%ˆØŸ™‰ˆ�Ø‘ˆØ‘ˆÜ"ˆŒØ�R‹<ð ˜2˜q ! Q¨Ð.ˆD�HØ�s‹]ð ˜A˜q " eÐ4ˆD�HØ�s‹]ð ˜1˜b ! V¨QÐ/ˆD�HØ�q‹[Ü�K‰KØKÈVôô *¨$¯(©(°D·M±MÓBÑˆ�Ø‘ˆØ‘ˆà�HÓÜ" 4§8¡8¨a°°A°r¸B¸3ÀÐ-CÓDˆD�Hà�f‹_Ü" 4§8¡8¨a°°A°q¸2¸#À¸sÐ-CÓDˆD�Hð ˜	Ó!Ü—‘Ð6¸Ô>Ü&ˆDŒHØÐˆEØŒ
ØŒØ�x‰xˆó    Ú
Annotationc              #   óh  #   • [        U R                  R                  S5      5      nUc  g[        U[        5      (       d  [
        R                  SU5        gU H  n [        R                  X 5      v •  M     g! [        [        [        4 a!  n[
        R                  SX#5         SnAMQ  SnAff = f7f)z%Lazily iterate over page annotations.ÚAnnotsNzInvalid Annots list: %rzInvalid object %r in Annots: %s)r,   rO   r]   rj   rk   ra   rb   r€   Ú	from_dictr`   re   r   )rl   ÚalistÚobjÚes       ro   ÚannotationsÚPage.annotationsü   s�   é € ô ˜Ÿ™Ÿ™¨Ó1Ó2ˆØ‰=ØÜ˜%¤×&Ñ&Ü�K‰KÐ1°5Ô9ØÛˆCðÜ ×*Ñ*¨3Ó5Ô5ò øô œz¬>Ð:ó Ü—‘Ð=¸sÔFÝûðüs0   ‚AB2ÁA9Á4B2Á9B/ÂB*Â$B2Â*B/Â/B2c                 ó,   • [        U R                  5      $ )z%Get associated document if it exists.)r6   r[   ©rl   s    ro   rM   ÚPage.doc  s   € ô ˜tŸ{™{Ó+Ð+r   c              #   óœ   #   • U R                    H  n [        U5      v •  M     g! [         a    [        R	                  SU5         M9  f = f7f)z Return resolved content streams.z Found non-stream in contents: %rN)ri   r-   r`   ra   rb   )rl   r…   s     ro   ÚstreamsÚPage.streams  sG   é € ð —>”>ˆCðEÜ" 3Ó'Ô'ò "øô ó EÜ—‘Ð>À×DðEüs%   ‚A“% A¥ A	ÁAÁA	Á	Ac                 ó(   • U R                   u  pp2X1-
  $ ©z.Width of the page in default user space units.©rc   )rl   rx   Ú_rz   s       ro   r|   Ú
Page.width  s   € ð —}‘}‰ˆˆrØ‰wˆr   c                 ó(   • U R                   u  ppX2-
  $ r�   r‘   )rl   r’   ry   r{   s       ro   r}   ÚPage.height   s   € ð —}‘}‰ˆˆqØ‰wˆr   c              #   óf   #   • [        U R                  U R                  5       H	  u  pUv •  M     g7f)z1Iterator over PDF objects in the content streams.N)r   ri   rM   )rl   r’   r…   s      ro   rn   ÚPage.contents&  s'   é € ô $ D§N¡N°D·H±HÖ=‰FˆAØŒIò >ùs   ‚/1r   c                 ó"   • U R                  5       $ )z"Iterator over lazy layout objects.)ÚinterprŠ   s    ro   Ú__iter__ÚPage.__iter__,  s   € à�{‰{‹}Ðr   Úfilter_classesÚrestrict_opsc                 ó.   • [        U U R                  UUS9$ )N©rœ   r�   )r   ri   )rl   rœ   r�   s      ro   r™   ÚPage.interp0  s!   € ô
 ØØ�N‰NØ)Ø%ñ	
ð 	
r   r   c                 ó,   • U R                  [        5      $ )z Iterator over lazy path objects.)Úflattenr   rŠ   s    ro   ÚpathsÚ
Page.paths<  ó   € ð �|‰|œJÓ'Ð'r   r   c                 ó,   • U R                  [        5      $ )z!Iterator over lazy image objects.)r¢   r   rŠ   s    ro   ÚimagesÚPage.imagesA  s   € ð �|‰|œKÓ(Ð(r   r   c                 ó,   • U R                  [        5      $ )z Iterator over lazy text objects.©r¢   r   rŠ   s    ro   ÚtextsÚ
Page.textsF  r¥   r   r   c              #   ó\   #   • U R                  [        5       H  nU Sh  v•N   M     g N	7f)z!Iterator over lazy glyph objects.Nrª   )rl   Útexts     ro   ÚglyphsÚPage.glyphsK  s$   é € ð —L‘L¤Ö,ˆDØ�OŠOò -Ùùs   ‚, *¡
,r   c              #   óÆ   ^#   • SSK Jn  S[        S   SU[           S[        S   4U4S jjmT" U [        5       5       H  n[        U[        5      (       d  M  Uv •  M      g	7f)
a  Return resolved and rendered Form XObjects.

This does *not* return any image or PostScript XObjects.  You
can get images via the `images` property.  Apparently you
aren't supposed to use PostScript XObjects for anything, ever.

Note that these are the XObjects as rendered on the page, so
you may see the same named XObject multiple times.  If you
need to access their actual definitions you'll have to look at
`page.resources`.

This will also return Form XObjects within Form XObjects,
except in the case of circular reference chains.
r   ©ÚSetÚitorr   ÚparentsrS   r   c              3   óî   >#   • U  Hh  n[        U[        5      (       d  M  UR                  R                  c  SOUR                  R                  nX1;  d  MP  Uv •  T" X!U1-  5       S h  v•N   Mj     g  N	7f)Nr   )rj   r   ÚstreamÚobjid)r´   rµ   r…   Ú	stream_idÚxobjects_ones       €ro   rº   Ú#Page.xobjects.<locals>.xobjects_oned  se   øé € ó �Ü˜c¤=×1Ó1Ø%(§Z¡Z×%5Ñ%5Ñ%=¡À3Ç:Á:×CSÑCS�IØ Õ/Ø!š	Ù#/°À	¸{Ñ5JÓ#K×KÒKò ñ
 Lùs   ƒA5 2A5ÁA5Á)A3Á*
A5N)Útypingr³   r   rg   r   Úsetrj   r   )rl   r³   r…   rº   s      @ro   ÚxobjectsÚPage.xobjectsQ  sa   øé € õ" 	ð	LÜ˜?Ñ+ð	LØ69¼#±hð	Lä�oÑ&÷	Lñ   ¤c£eÖ,ˆCÜ˜#œ}×-Ó-Ø”	ò -ùs   ƒAA!Á	A!c              #   óv   #   • U R                    H%  n[        UR                  5       H	  u  p#Uv •  M     M'     g7f)z,Iterator over tokens in the content streams.N)ri   r   Úbuffer)rl   r·   r’   Útoks       ro   ÚtokensÚPage.tokensr  s/   é € ð —n”nˆFÜ §¡Ö.‘�Ø”	ó /ò %ùs   ‚79c                 óT   • SU R                   ;   a  [        U R                   S   5      $ g)z&Parent tree key for this page, if any.ÚStructParentsN)rO   r(   rŠ   s    ro   Ú
parent_keyÚPage.parent_keyy  s'   € ð ˜dŸj™jÓ(Ü˜TŸZ™Z¨Ñ8Ó9Ð9Ør   c                 óô  • U R                   b  U R                   $ [        U R                  / 5      U l         U R                  R                  c  U R                   $ U R
                  nUc  U R                   $  [        U R                  U R                  R                  R                  U   5      U l         U R                   $ ! [        [        4 a+  n[        R                  SX5         SnAU R                   $ SnAff = f)a  Mapping of marked content IDs to logical structure elements.

This is a sequence of logical structure elements, or `None`
for unused marked content IDs.  Note that because structure
elements may contain multiple marked content sections, the
same element may occur multiple times in this list.

It also has `find` and `find_all` methods which allow you to
access enclosing structural elements (you can also use the
`parent` method of elements for that)

Note: This is not the same as `playa.Document.structure`.
    PDF documents have logical structure, but PDF pages **do
    not**, and it is dishonest to pretend otherwise (as some
    code I once wrote unfortunately does).  What they do have
    is marked content sections which correspond to content
    items in the logical structure tree.

NzInvalid StructParents: %r (%s))rI   r/   r\   rM   Ú	structurerÇ   Úparent_treeÚ
IndexErrorr`   ra   rb   )rl   rÇ   r†   s      ro   rÊ   ÚPage.structure€  sÎ   € ð* �?‰?Ñ&Ø—?‘?Ð"Ü'¨¯©°bÓ9ˆŒØ�8‰8×ÑÑ%Ø—?‘?Ð"Ø—_‘_ˆ
ØÑØ—?‘?Ð"ð	IÜ+Ø—‘˜dŸh™h×0Ñ0×<Ñ<¸ZÑHóˆDŒOð
 �‰Ðøô œIÐ&ó 	IÜ�K‰KÐ8¸*×HÐHØ�‰Ðûð	Iús   Á4<B< Â<C7ÃC2Ã2C7c                 óˆ   • U R                   b  U R                   $ [        U R                  5       5      U l         U R                   $ )aT  A [`ContentSequence`][playa.content.ContentSequence] containing
content objects associated with the structural elements in
[`structure`][playa.page.Page.structure].  They consist of a
sequence with the same indices (these are the marked content
IDs) as the structure so can be zipped:

    for element, contents in zip(page.structure,
                                 page.marked_content):
        for obj in contents:
            ...  # do something with it

Or you can also access the contents of a single element:

    for obj in page.marked_content[mcid]:
        ... # do something with it

)rJ   r   r™   rŠ   s    ro   Úmarked_contentÚPage.marked_content¥  s;   € ð& × Ñ Ñ,Ø×(Ñ(Ð(Ü /°·±³Ó >ˆÔØ×$Ñ$Ð$r   c                 ó´   • U R                   b  U R                   $ [        U R                  R                  S5      U R                  5      U l         U R                   $ )aü  Mapping of resource names to fonts for this page.

Note: This is not the same as `playa.Document.fonts`.
    The resource names (e.g. `F1`, `F42`, `FooBar`) here are
    specific to a page (or Form XObject) resource dictionary
    and have no relation to the font name as commonly
    understood (e.g. `Helvetica`,
    `WQERQE+Arial-SuperBold-HJRE-UTF-8`).  Since font names are
    generally considered to be globally unique, it may be
    possible to access fonts by them in the future.

Note: This does not include fonts specific to Form XObjects.
    Since it is possible for the resource names to collide,
    this will only return the fonts for a page and not for any
    Form XObjects invoked on it.  You may use
    `XObjectObject.fonts` to access these.

r;   )rK   r   r_   r]   rM   rŠ   s    ro   ÚfontsÚ
Page.fonts½  sC   € ð( �=‰=Ñ$Ø—=‘=Ð Ü# D§N¡N×$6Ñ$6°vÓ$>ÀÇÁÓIˆŒØ�}‰}Ðr   c                 ó@   • SU R                   < SU R                  < S3$ )Nz<Page: Resources=z, MediaBox=Ú>)r_   rc   rŠ   s    ro   Ú__repr__ÚPage.__repr__Ö  s"   € Ø" 4§>¡>Ñ"4°KÀÇÁÑ?PÐPQÐRÐRr   c                 ó   • g ©N© rŠ   s    ro   r¢   ÚPage.flattenÙ  s   € Ø47r   Úfilter_classc                 ó   • g rÙ   rÚ   )rl   rÜ   s     ro   r¢   rÛ   Ü  s   € Ø?Br   c                 ó   • g rÙ   rÚ   )rl   rÜ   r�   s      ro   r¢   rÛ   ß  s   € ð r   c              #   óØ   ^^^#   • SSK Jn  Ub	  [        U1mOSmS[        S   SU[           S[
        S   4UUU4S jjmT" U R                  TTS	9[        5       5       H  nUv •  M	     g7f)
z;Iterate over content objects, recursing into form XObjects.r   r²   Nr´   r   rµ   rS   c              3   ó
  >#   • U  Hv  n[        U[        5      (       aZ  UR                  R                  c  SOUR                  R                  nX1;  a$  T" UR	                  TTS9X1-  5       S h  v•N   Mp  Mr  Uv •  Mx     g  N7f)Nr   rŸ   )rj   r   r·   r¸   r™   )r´   rµ   r…   r¹   rœ   Úflatten_oner�   s       €€€ro   rá   Ú!Page.flatten.<locals>.flatten_oneõ  sˆ   øé € ó �Ü˜c¤=×1Ñ1Ø%(§Z¡Z×%5Ñ%5Ñ%=¡À3Ç:Á:×CSÑCS�IØ Ó/Ù#.ØŸJ™JØ/=ÈLð 'ð ð $ kÑ1ó	$÷ ò ñ 0ð ”Iò ñùs   ƒA,BÁ/BÁ0BrŸ   )r¼   r³   r   r   rg   r   r™   r½   )rl   rÜ   r�   r³   r…   rœ   rá   s     `  @@ro   r¢   rÛ   ä  sƒ   úé € õ 	àÑ#äØðE‰Nð
 "ˆNð	Ü˜?Ñ+ð	Ø69¼#±hð	ä�oÑ&÷	ñ 	ñ  Ø�K‰K ~ÀLˆKÐQÜ‹Eö
ˆCð ŒIò	
ùs   …A%A*©Úbboxrä   c                ót   • U R                   R                  (       a  U R                  US9$ U R                  US9$ )a—  Do some best-effort text extraction.

This necessarily involves a few heuristics, so don't get your
hopes up.  It will attempt to use marked content information
for a tagged PDF, otherwise it will fall back on the character
displacement and line matrix to determine word and line breaks.

Args:
  bbox: If not `None`, only text objects which intersect this
        rectangle will be extracted.

Note: `bbox` operates on text objects, not glyphs.
  You may be surprised to get a lot more text than you
  expected if you call this with a `bbox`.  This is because,
  for efficiency reasons, the intersection check is performed
  on text objects (strings in the content stream) rather than
  glyphs (individual characters).  For many tasks like table
  extraction, this is actually what you want.  Otherwise, you
  will need to use `playa.utils.intersect_rects` on the
  individual glyph bboxes, which is, of course, slow.
rã   )rM   Ú	is_taggedÚextract_text_taggedÚextract_text_untagged)rl   rä   s     ro   Úextract_textÚPage.extract_text  s9   € ð, �8‰8××Ø×+Ñ+°Ð+Ð6Ð6à×-Ñ-°4Ð-Ð8Ð8r   c          
      ór  • SSS[         S[        S[        [        [        4   4S jnSnSn/ n/ nU R	                  [
        [        S	9nU GH3  nUR                  R                  c  M  UR                  R                  R                  n	UR                  u  p«U	(       a  UOU
nU(       aF  U R                  X„5      (       a0  UR                  S
R                  U5      5        UR                  5         U(       a2  XÃ-
  S:”  a*  US   R                  S5      (       d  UR                  S5        U" X‰U5      u  pÓUc  UR                  U5        O4U	(       a  X£4OX;4u  pï[!        X«4Xï4U5      (       a  UR                  U5        X«4nGM6     U(       a   UR                  S
R                  U5      5        SR                  U5      $ )z(Get text from a page of an untagged PDF.r…   r   ÚverticalÚprev_endrS   c                 óV  • / nU  H�  nUR                   u  pVU(       a  UOUnU(       a)  Xr-
  S:”  a!  U(       a  US   S:w  a  UR                  S5        UR                  b  UR                  UR                  5        UR                  u  p‰Xq(       a  U	OU-   nM‘     SR	                  U5      U4$ )z#Try to get text from a text object.ç      à?rt   Ú Ú )ÚoriginÚappendr®   ÚdisplacementÚjoin)
r…   rì   rí   ÚcharsÚglyphÚxÚyÚoffÚdxÚdys
             ro   Ú_extract_text_from_objÚ:Page.extract_text_untagged.<locals>._extract_text_from_obj)  s—   € ð  "ˆEÛ�Ø—|‘|‘�Þ#‘a¨�æ ¡°Ó 4Þ  r¡¨cÓ!1ØŸ™ SÔ)Ø—:‘:Ñ)Ø—L‘L §¡Ô,Ø×+Ñ+‘�Ø­¡"°bÑ9’ñ ð —7‘7˜5“> 8Ð+Ð+r   g        N©rÜ   r�   rñ   rï   rt   rð   Ú
)ÚboolÚfloatr   Ústrr¢   r   ÚTEXT_OPERATORSÚgstateÚfontrì   rò   Ú
_next_lineró   rõ   ÚclearÚendswithÚ_crosses_bbox)rl   rä   rý   rí   Úprev_originÚlinesÚstringsr´   r®   rì   rû   rü   rú   ÚtextstrÚexÚeys                   ro   rè   ÚPage.extract_text_untagged&  sy  € ð	,Øð	,Ü)-ð	,Ü9>ð	,ä”3œ�:Ñô	,ð$ ˆØ*.ˆØˆØˆØ�|‰|¬Ä.ˆ|ÐQˆÜˆDØ�{‰{×ÑÑ'ÙØ—{‘{×'Ñ'×0Ñ0ˆHð —[‘[‰FˆBÞ ‘" bˆCÞ˜4Ÿ?™?¨4×=Ñ=Ø—‘˜RŸW™W WÓ-Ô.Ø—‘”æ˜3™>¨CÓ/¸À¹×8LÑ8LÈS×8QÑ8QØ—‘˜sÔ#Ù 6°tÀsÓ KÑˆGØ‰|Ø—‘˜wÕ'æ+3˜"™¸(¸‘�Ü  " ¨B¨8°T×:Ñ:Ø—N‘N 7Ô+Ø˜&‹Kñ- ö. Ø�L‰L˜Ÿ™ Ó)Ô*Ø�y‰y˜ÓÐr   r®   Úprev_offsetc                 ó  • Uc  gUR                   R                  c  gUc  gUR                  nUR                   R                  R                  (       a  US   US   -
  nUS:  $ US   US   -
  nU R                  S:X  a  U* nUS:  $ UnUS:  $ )NFr   ru   r=   )r  r  rò   rì   rR   )rl   r®   r  ÚoffsetÚline_offsetrü   s         ro   r  ÚPage._next_line[  s¨   € ð ‰<ØØ�;‰;×ÑÑ#ØØÑØØ—‘ˆð �;‰;×Ñ×$×$Ø  ™) k°!¡nÑ4ˆKð ˜Q‰Ðð ˜‘˜[¨™^Ñ+ˆBØ�z‰z˜XÓ%Ø!˜c�ð ˜Q‰Ðð !�Ø˜Q‰Ðr   c                ó2  • / n/ nSnSnU R                  [        [        S9n[        R                  " U[
        R                  " S5      5       GHü  u  pxSn	Ub  UR                  S:X  a  U H  n	U	R                  nM     M2  UR                  R                  S5      n
U
cÖ  UR                  S:H  n/ nU H­  n	Uc6  UR                  U(       a  U	R                  SSS2   OU	R                  5        M<  U	R                  u  pÞU	R                  u  nnXß-   UU-   nn[        XÞ4UU4U5      (       d  My  UR                  U(       a  U	R                  SSS2   OU	R                  5        M¯     SR                  U5      nO+[!        U
["        5      (       d   e[%        U
5      nU H  nM     UR'                  S	S5      nUR(                  U:w  af  U R+                  X•5      (       aD  UR-                  [.        R0                  " SR                  U5      5      5        UR3                  5         UR(                  nUR                  U5        U	c  GMð  U	R                  nGMÿ     U(       a4  UR-                  [.        R0                  " SR                  U5      5      5        S
R                  U5      $ )z%Get text from a page of a tagged PDF.Nrÿ   ÚmcsÚArtifactÚ
ActualTextÚReversedCharsrt   rñ   ô   Â­r   )r¢   r   r  Ú	itertoolsÚgroupbyÚoperatorÚ
attrgetterÚtagrò   Úpropsr]   ró   rö   rô   r
  rõ   rj   Úbytesr0   ÚreplaceÚmcidr  ÚextendÚtextwrapÚwrapr  )rl   rä   r  r  Ú	prev_mcidr  r´   r  r«   r®   Úactual_textÚreversedÚcrø   rù   rû   rü   r  r  rö   r’   s                        ro   rç   ÚPage.extract_text_taggedt  s  € àˆØˆØ&*ˆ	Ø*.ˆð �|‰|¬Ä.ˆ|ÐQˆÜ#×+Ò+¨D´(×2EÒ2EÀeÓ2L×M‰JˆCØ,0ˆDð ‰{˜cŸg™g¨Ó3Û!�DØ"&§+¡+’Kñ "áØŸ)™)Ÿ-™-¨Ó5ˆKØÑ"ØŸ7™7 oÑ5�Ø�Û!�DØ‘|ØŸ™¶X §¡©D¨b¨DÒ!1À4Ç:Á:ÖNà#Ÿ{™{™˜Ø!%×!2Ñ!2™˜˜BØ"#¡&¨!¨b©&˜B˜Ü(¨!¨°"°b°¸4×@Ó@ØŸH™H¾ T§Z¡Z±°"°Ò%5ÀtÇzÁzÖRñ "ð Ÿ™ ›
‘ä! +¬u×5Ñ5Ð5Ð5ä# KÓ0�ã�AÙñ ð —M‘M &¨"Ó-ˆEà�x‰x˜9Ó$Ø—?‘? 4×5Ñ5Ø—L‘L¤§¢¨r¯w©w°wÓ/?Ó!@ÔAØ—M‘M”OØŸH™H�	Ø�N‰N˜5Ô!ØÔØ"Ÿk™k“ñS NöT Ø�L‰LœŸš r§w¡w¨wÓ'7Ó8Ô9Ø�y‰y˜ÓÐr   )ri   rK   rJ   rI   rO   rf   rw   r[   rP   r^   rc   rQ   rN   r\   r_   rm   rR   )r   r=   )rS   r:   )NN)?Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__rI   r   r/   Ú__annotations__rJ   r   rK   r   r  rL   r	   rg   r   ÚDeviceSpacerp   r"   rh   Úpropertyr   r‡   rM   r    r�   r  r|   r}   r   rn   rš   r   r   r   r$   r™   r£   r§   r«   r¯   r¾   r   rÃ   rÇ   rÊ   rÏ   rÒ   rÖ   r   r¢   r@   r&   ré   rè   r   r%   r  r  rç   Ú__static_attributes__rÚ   r   ro   rG   rG   g   s¢  ‡ ñð. .2€J��m TÐ)Ñ*Ó1Ø59Ð�e˜O¨TÐ1Ñ2Ó9Ø26€Hˆe�G˜C ˜KÑ(¨$Ð.Ñ/Ó6Ø-1€Hˆe�D˜˜c™‘O TÐ)Ñ*Ó1ð Ø%ñ=,àð=,ð ð=,ð ð	=,ð
 �S˜$�YÑð=,ð ð=,ð ð=,ð 
õ=,ð~7 [ð 7¸#ð 7À&ô 7ðr ð˜X lÑ3ó ó ðð ó,ó ð,ð ðE˜ -Ñ0ó Eó ðEð ð�uó ó ðð
 ð˜ó ó ðð
 ð˜( 9Ñ-ó ó ðð
˜( ?Ñ3ô ð HLØ;?ñ

à˜j¨¨mÑ)<Ñ=¸tÐCÑDð

ð ˜J yÑ1°4Ð7Ñ8ð

ð 
�-Ñ	 õ	

ð ð(�x Ñ-ó (ó ð(ð ð)˜ Ñ/ó )ó ð)ð ð(�x Ñ-ó (ó ð(ð ð˜ Ñ/ó ó ðð
 ð˜( ?Ñ3ó ó ðð@ ð˜ ™ó ó ðð ð˜E # t )Ñ,ó ó ðð ð"˜=ó "ó ð"ðH ð% ó %ó ð%ð. ð�w˜s F˜{Ñ+ó ó ðð0S˜#ô Sð Ø7˜ /Ñ2Ó7ó Ø7àØB D¨¡HÐB°¸"±ÓBó ØBàðØ  ™HðØ4>¸yÑ4Iðà	�"‰óó ðð /3Ø;?ñ%à˜D $ r¡(˜NÑ+ð%ð ˜J yÑ1°4Ð7Ñ8ð%ð 
�%˜˜OÐ+Ñ,Ñ	-õ	%ðN 9=ò 9 E¨$°¨*Ñ$5ð 9Àõ 9ð6 BFò 3 ¨U°4¸°:Ñ->ð 3 È#õ 3 ðjØ˜* dÐ*Ñ+ðØ:?ÀÀtÀÑ:Lðà	ôð2 @Dò 5 ¨5°°t°Ñ+<ð 5 È÷ 5 ð 5 r   rG   rò   Údestinationrä   rS   c                 óR   • U u  p4Uu  pV[        X4XV4U5      u  pxpšX—:„  =(       a    X¨:¬  $ rÙ   )r3   )rò   r7  rä   rø   rù   rû   rü   Úix0Úiy0Úix1Úiy1s              ro   r
  r
  ¬  s4   € Ø�D€AØ�F€Bä(¨!°¨¸Ó>Ñ€CˆcØ‰9×#˜™Ð#r   c                   ó   • \ rS rSr% Sr\\S'   \\S'   \\S'   \	\\
4   \S'   \S\
S\S	S 4S
 j5       r\S	\4S j5       r\S	\4S j5       r\S	\S   4S j5       r\S	\\S4   4S j5       r\S	\\S4   4S j5       r\S	\\S4   4S j5       rSrg)r€   i´  ai  PDF annotation (PDF 1.7 section 12.5).

Attributes:
  type: Type of annotation.
  rect: Annotation rectangle (location on page) in *default user space*
  bbox: Annotation rectangle in *device space*
  parent: Structure element associed with this annotation, if any.
  props: Annotation dictionary containing all other properties
         (PDF 1.7 sec. 12.5.2).
Ú_pagerefÚtypeÚrectr"  r…   r<   rS   c                 óô   • [        U5      nUR                  S5      nUb  [        U[        5      (       d  [	        SU< 35      e[        UR                  S5      5      nU " UR                  [        U5      UUS9$ )NÚSubtypezInvalid annotation Subtype r&   )r>  r?  r@  r"  )r'   r]   rj   r#   r   r+   r\   r)   )Úclsr…   r<   ÚannotÚsubtyper@  s         ro   rƒ   ÚAnnotation.from_dictÆ  sm   € ä˜3“ˆØ—)‘)˜IÓ&ˆØ‰?¤*¨W´i×"@Ñ"@Ý ÂGÐ!MÓNÐNÜ˜%Ÿ)™) FÓ+Ó,ˆÙØ—\‘\Ü˜gÓ&ØØñ	
ð 	
r   c                 ó,   • [        U R                  5      $ )z$Containing page for this annotation.)r7   r>  rŠ   s    ro   r<   ÚAnnotation.pageÔ  s   € ô ˜4Ÿ=™=Ó)Ð)r   c                 óV   • [        U R                  R                  U R                  5      $ )z1Bounding box for this annotation in device space.)r4   r<   rw   r@  rŠ   s    ro   rä   ÚAnnotation.bboxÙ  s   € ô ˜dŸi™iŸm™m¨T¯Y©YÓ7Ð7r   )r.   Nc                 óÀ  • [        U S5      (       a  U R                  $ SU l         [        U R                  R	                  S5      5      nUc  U R                  $ U R
                  R                  U   U l        U R                  $ ! [         a$    [        R                  SU 5         U R                  $ [         a$    [        R                  SU 5         U R                  $ f = f)z0The enclosing logical structure element, if any.Ú_parentNÚStructParentz'Annotation has invalid StructParent: %rz(Annotation StructParent out of range: %r)ÚhasattrrL  r(   r"  r]   r<   rÊ   r`   ra   rb   rÌ   )rl   rÇ   s     ro   ÚparentÚAnnotation.parentÞ  sÃ   € ô �4˜×#Ñ#Ø—<‘<ÐØ/3ˆŒð	JÜ" 4§:¡:§>¡>°.Ó#AÓBˆJØÑ!Ø—|‘|Ð#ØŸ9™9×.Ñ.¨zÑ:ˆDŒLð
 �|‰|Ðøô	 ó 	IÜ�K‰KÐAÀ4ÕHð �|‰|Ðô ó 	JÜ�K‰KÐBÀDÕIØ�|‰|Ðð	Jús   ¦2B ÁB Â CÂ0CÃCNc                 óÌ   • [        U R                  R                  S5      5      nUc  g[        U[        [
        45      (       d  [        R                  SU5        g[        U5      $ )zText contents of annotation.rZ   NzInvalid annotation contents: %r©	r,   r"  r]   rj   r#  r  ra   rb   r0   )rl   rn   s     ro   rn   ÚAnnotation.contentsï  sR   € ô ˜DŸJ™JŸN™N¨:Ó6Ó7ˆØÑØÜ˜(¤U¬C L×1Ñ1Ü�K‰KÐ9¸8ÔDØÜ˜8Ó$Ð$r   c                 óÌ   • [        U R                  R                  S5      5      nUc  g[        U[        [
        45      (       d  [        R                  SU5        g[        U5      $ )z6Annotation name, uniquely identifying this annotation.ÚNMNzInvalid annotation name: %rrR  )rl   Únames     ro   rV  ÚAnnotation.nameú  sQ   € ô ˜Ÿ
™
Ÿ™ tÓ,Ó-ˆØ‰<ØÜ˜$¤¬ ×-Ñ-Ü�K‰KÐ5°tÔ<ØÜ˜4Ó Ð r   c                 óÌ   • [        U R                  R                  S5      5      nUc  g[        U[        [
        45      (       d  [        R                  SU5        g[        U5      $ )zðString describing date and time when annotation was most recently
modified.

The date *should* be in the format `D:YYYYMMDDHHmmSSOHH'mm`
but this is in no way required (and unlikely to be implemented
consistently, if history is any guide).
ÚMNz(Invalid annotation modification date: %rrR  )rl   Úmtimes     ro   rZ  ÚAnnotation.mtime  sQ   € ô ˜Ÿ™Ÿ™¨Ó,Ó-ˆØ‰=ØÜ˜%¤%¬ ×.Ñ.Ü�K‰KÐBÀEÔJØÜ˜5Ó!Ð!r   )rL  )r.  r/  r0  r1  r2  r5   r3  r  r&   r   r   ÚclassmethodrG   rƒ   r5  r<   rä   r   rO  rn   rV  rZ  r6  rÚ   r   ro   r€   r€   ´  s  ‡ ñ	ð ÓØ
ƒIØ
ƒJØ��Y�ÑÓàð
˜Ið 
¨Tð 
°ló 
ó ð
ð ð*�dó *ó ð*ð ð8�dó 8ó ð8ð ð˜˜oÑ.ó ó ðð  ð%˜%  T 	Ñ*ó %ó ð%ð ð!�e˜C ˜IÑ&ó !ó ð!ð ð"�u˜S $˜YÑ'ó "ó ó"r   r€   )Tr2  r  Úloggingr  r'  Údataclassesr   r¼   r   r   r   r   r   r	   r
   r   r   r   r   r   r   Úplaya.contentr   r   r   r   r   r   r   Úplaya.exceptionsr   Úplaya.interpr   r   Úplaya.parserr   r   r   r   Úplaya.pdftypesr   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   Úplaya.structurer.   r/   Úplaya.utilsr0   r1   r2   r3   r4   Úplaya.workerr5   r6   r7   r8   r9   Úplaya.documentr:   Ú
playa.fontr;   Ú	getLoggerr.  ra   r4  r@   r  rG   r  r
  r€   rÚ   r   ro   Ú<module>rj     s¶  ðñó Û Û Û Ý !÷÷ ÷ õ ÷ ÷ ñ õ ,ß 5ß ?Ó ?÷÷ ÷ ÷ ñ ÷" 3÷õ ÷ YÕ XæÝ'Ýà×Ò˜Ó!€ð Ð9Ñ:€ÙˆT˜Ñ'€áˆƒJÙˆƒKÙˆƒKÙˆƒKÙˆƒIÙˆƒIÙˆƒJÙˆƒJÙˆƒJÙˆƒJÙˆƒJÙˆƒJÙˆƒIÙˆƒIÙˆƒJÙˆƒJÙˆƒJÙˆƒJÙˆƒJÙˆƒJÙˆƒJÙˆƒJÙˆƒJÙˆƒJÙˆƒJð3€ô:B	 ˆ8�MÑ"ô B	 ðJ$˜%ð $¨eð $¸4ð $ÀDô $ð ÷_"ð _"ó ñ_"r   