+
    yaÒjy,  ã                   óê   € R t ^ RIt^ RIHtHtHt ^RIHt ^RIH	t	 ^RI
HtHtHtHtHt ]'       d   ^ RIHt RtRtR	 R
 ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR R ltR# )u£  
Page labels are shown by PDF viewers as "the page number".

A page has a numeric index, starting at 0. Additionally, the page
has a label. In the most simple case:

    label = index + 1

However, the title page and the table of contents might have Roman numerals as
page labels. This makes things more complicated.

Example 1
---------

>>> reader.root_object["/PageLabels"]["/Nums"]
[0, IndirectObject(18, 0, 139929798197504),
 8, IndirectObject(19, 0, 139929798197504)]
>>> reader.get_object(reader.root_object["/PageLabels"]["/Nums"][1])
{'/S': '/r'}
>>> reader.get_object(reader.root_object["/PageLabels"]["/Nums"][3])
{'/S': '/D'}

Example 2
---------
The following is a document with pages labeled
i, ii, iii, iv, 1, 2, 3, A-8, A-9, ...

1 0 obj
    << /Type /Catalog
       /PageLabels << /Nums [
                        0 << /S /r >>
                        4 << /S /D >>
                        7 << /S /D
                             /P ( A- )
                             /St 8
                        >>
                        % A number tree containing
                        % three page label dictionaries
                        ]
                   >>
    ...
    >>
endobj


Â§12.4.2 PDF Specification 1.7 and 2.0
=====================================

Entries in a page label dictionary
----------------------------------
The /S key:
D       Decimal Arabic numerals
R       Uppercase Roman numerals
r       Lowercase Roman numerals
A       Uppercase letters (A to Z for the first 26 pages,
                           AA to ZZ for the next 26, and so on)
a       Lowercase letters (a to z for the first 26 pages,
                           aa to zz for the next 26, and so on)
N)ÚTYPE_CHECKINGÚOptionalÚcast)ÚPdfCommonDocProtocol)Úlogger_warning)ÚArrayObjectÚDictionaryObjectÚ
NullObjectÚNumberObjectÚis_null_or_none)ÚCallableiŸ  i   c                ó0   € V ^8„  d   QhR\         R\        /# )é   ÚnumÚreturn©ÚintÚstr)Úformats   "ÚH/opt/data/home/.local/lib/python3.14/site-packages/pypdf/_page_labels.pyÚ__annotate__r   X   s   € ÷ ñ ¬ð ´ñ ó    c                 óÞ   € V ^ 8:  d   \        R4      hV \        8”  d   \        R4      h. ROp. pV F)  w  r4\        W4      w  rPVP                  WE,          4       K+  	  RP	                  V4      # )é    úExpecting a positive number.zNumber is out of range.Ú ))iè  ÚM)i„  ÚCM)iô  ÚD)i�  ÚCD)éd   ÚC)éZ   ÚXC)é2   ÚL)é(   ÚXL)é
   ÚX)é	   ÚIX)é   ÚV)é   ÚIV)é   ÚI)Ú
ValueErrorÚMAXIMUM_ROMAN_NUMERALÚdivmodÚappendÚjoin)r   ÚromanÚresultÚvalueÚsymbolÚcounts   &     r   Únumber2uppercase_roman_numeralr<   X   sn   € Ø
ˆa„xÜÐ7Ó8Ð8Ø
Ô"Ô"ÜÐ2Ó3Ð3ò€Eð  €FÛ‰ˆÜ˜CÓ'‰
ˆØ�‰�f•nÖ%ñ ð �7‰7�6‹?Ðr   c                ó0   € V ^8„  d   QhR\         R\        /# ©r   Únumberr   r   )r   s   "r   r   r   u   s   € ÷ :ñ :¬3ð :´3ñ :r   c                 ó4   € \        V 4      P                  4       # ©N)r<   Úlower©r?   s   &r   Únumber2lowercase_roman_numeralrD   u   s   € Ü)¨&Ó1×7Ñ7Ó9Ð9r   c                ó0   € V ^8„  d   QhR\         R\        /# r>   r   )r   s   "r   r   r   y   s   € ÷ @ñ @¤Cð @¬Cñ @r   c                 óØ   € V ^ 8:  d   \        R4      h\        V ^,
          ^4      w  rV^,           pV\        8”  d   \        R4      h\        P                  V,          V^,           ,          # )r   r   zNumber is too large.)r2   r4   ÚMAXIMUM_PAGE_LABEL_LENGTHÚstringÚascii_uppercase)r?   ÚrepetitionsÚpositionÚlengths   &   r   Únumber2uppercase_letterrM   y   s`   € Ø�„{ÜÐ7Ó8Ð8ä" 6¨A¥:¨rÓ2Ñ€KØ˜1�_€FØÔ)Ô)ÜÐ/Ó0Ð0Ü×!Ñ! (Õ+¨{¸Q­Õ?Ð?r   c                ó0   € V ^8„  d   QhR\         R\        /# r>   r   )r   s   "r   r   r   „   s   € ÷ 3ñ 3¤Cð 3¬Cñ 3r   c                 ó4   € \        V 4      P                  4       # rA   )rM   rB   rC   s   &r   Únumber2lowercase_letterrP   „   s   € Ü" 6Ó*×0Ñ0Ó2Ð2r   c                ó<   € V ^8„  d   QhR\         R\        R\        /# )r   Údictionary_objectÚindexr   )r   r   r   )r   s   "r   r   r   ˆ   s"   € ÷ ;ñ ;Ô+;ð ;ÄCð ;ÌCñ ;r   c                 ó®  € \        \        V R ,          4      p\        V4      p^ pRp^ pWC8  du   V^,           V8¼  d   \        R\        R7       MTW$,          pW$^,           ,          P                  4       pV^,           V8X  d   M W$^,           ,          V8”  d   MV^,          pKz  RR R\        R\        R\        R\        R	\        /p\        V\        4      '       g   \        V^,           4      # VP                  R
^4      p\        \        VP                  RR4      4      p	VP                  VP                  R4      4      p
V
f4   \        R\        VP                  R4      R7       \        V^,           4      #  Wš! W,
          V,           4      ,           #   \        \        3 d1   p\        R\        TT	TR7       \        T^,           4      u Rp?# Rp?ii ; i)ú/NumsNz(Ignoring last /Nums key without a value.©Úsourcec                 ó   € R # )r   © )Ú_s   &r   Ú<lambda>Ú%get_label_from_nums.<locals>.<lambda>£   s   € ™r   z/Dz/Rz/rz/Az/az/Stz/Pr   z/Sz?Ignoring unknown page label numbering style %(style)r in /Nums.)rW   ÚstylezZIgnoring malformed page label entry in /Nums (/St=%(start)r, /P=%(prefix)r): %(exception)s)rW   ÚstartÚprefixÚ	exception)r   r   Úlenr   Ú__name__Ú
get_objectr   r<   rD   rM   rP   Ú
isinstanceÚdictÚgetÚ	TypeErrorr2   )rR   rS   ÚnumsÚnums_lengthÚir9   Ústart_indexÚmr^   r_   Úmapping_functionr`   s   &&          r   Úget_label_from_numsrn   ˆ   s¢  € ô ”Ð.¨wÕ7Ó8€DÜ�d“)€KØ	€AØ€EØ€KØ
Œ/Øˆq�5�KÔÜØ:Ä8õð Ø•gˆØ˜•U•×&Ñ&Ó(ˆØˆq�5�KÔØØ�A•�;˜ÔØØ	ˆQ�Šà‰lØŒcØÔ,ØÔ,ØÔ%ØÔ%ð4€Aô �eœT×"Ò"Ü�5˜1•9‹~ÐØ�I‰I�e˜QÓ€EÜ”#�u—y‘y  rÓ*Ó+€FØ—u‘u˜UŸY™Y t›_Ó-ÐØÒäØMÜØ—)‘)˜D“/õ	
ô
 �5˜1•9‹~ÐðØÐ(¨Õ)<¸uÕ)DÓEÕEÐEøÜ”zÐ"ô 	äØhÜØØØõ	
ô �5˜1•9‹~Õûð	ús   Å8F ÆGÆ$%GÇ	GÇGc                ó<   € V ^8„  d   QhR\         R\        R\        /# )r   ÚreaderrS   r   )r   r   r   )r   s   "r   r   r   Æ   s'   € ÷ Jñ JÔ,ð J´Sð J¼Sñ Jr   c                ó‚  € \        \        V P                  4      pRV9  d   \        V^,           4      # VR,          P	                  4       p\        V\        4      '       g%   \        R\        VR7       \        V^,           4      # RV9   d   \        W14      # RV9   Ed   \        VR,          \        4      '       Ega   ^ pV^d8  EdW   VR,          P	                  4       p\        V\        4      '       g   \        R\        VR7       EMV EF  pVP	                  4       p\        V\        4      '       g   \        R\        R	7       K=  VP                  R
\        4       4      P	                  4       p\        V\        4      '       d   \        V4      ^8  d   \        R\        R	7       Kž  V^ ,          Tu;8:  d   V^,          8:  g   K½  M KÁ  \        VP                  RR4      4      '       g"   V^,          pV^d8X  d   \        R4      hTp EKN  \        Wa4      u # 	   \        R\        VR7       \        V^,           4      # )z•
See 7.9.7 "Number Trees".

Args:
    reader: The PdfReader
    index: The index of the page

Returns:
    The label of the page, e.g. "iv" or "4".

z/PageLabelsz1Page labels are not a dictionary: %(number_tree)s)rW   Únumber_treerU   z/Kidsz*Page label kids are not an array: %(kids)s)rW   Úkidsz6Ignoring kid which is not a dictionary in /PageLabels.rV   z/Limitsz>Ignoring kid with missing or malformed /Limits in /PageLabels.Nz"Too deep nesting is not supported.z6Could not reliably determine page label for %(index)d.)rW   rS   )r   r   Úroot_objectr   rc   rd   r   rb   rn   r	   r   rf   Úlistra   r   ÚNotImplementedError)rp   rS   Úrootrr   Úlevelrs   ÚkidÚlimitss   &&      r   Úindex2labelr{   Æ   sã  € ô Ô  &×"4Ñ"4Ó5€DØ˜DÔ Ü�5˜1•9‹~ÐØ�}Õ%×0Ñ0Ó2€KÜ�kÔ#3×4Ò4ÜØ?ÜØ#õ	
ô
 �5˜1•9‹~ÐØ�+ÔÜ" ;Ó6Ð6Ø�+Õ¤j°¸WÕ1EÄz×&RÓ&Rð ˆØ�c�kØ˜wÕ'×2Ñ2Ó4ˆDÜ˜d¤K×0Ò0ÜØ@Ü#Øõñ
 Ü�à—n‘nÓ&�Ü! #Ô'7×8Ò8Ü"ØPÜ'õñ ØŸ™ ¬J«LÓ9×DÑDÓF�Ü! &¬$×/Ò/´3°v³;À´?ä"ØXÜ'õñ Ø˜!•9 Ö2¨°­×2Ò2Ü*¨3¯7©7°7¸DÓ+A×BÒBà �
˜Ø  Cœ<Ü"5Ø Dó#ð ð '*˜ó Ü.¨sÓ:Ò:ñ; ðB äÐKÔT\ÐdiÕjÜˆu�q�y‹>Ðr   c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# )r   Úkeyr9   rh   r   N)r
   r   r   )r   s   "r   r   r     s0   € ÷ "ñ "Ü	ð"äð"ô ð"ð 
ñ	"r   c                óT  € \        V4      ^,          ^ 8w  d   \        R4      h\        V4      pV^ 8w  d    WV^,
          ,          8:  d   V^,
          pK&  V\        V4      8  d   WV,          8X  d   WV^,           &   R# VP                  W04       VP                  V^,           V4       R# )z¬
Insert a key, value pair in a Nums array.

See 7.9.7 "Number Trees".

Args:
    key: number key of the entry
    value: value of the entry
    nums: Nums array to modify

ú6A nums like array must have an even number of elementsN)ra   r2   Úinsert)r}   r9   rh   rj   s   &&& r   Únums_insertr�     s‚   € ô  ˆ4ƒy�1…}˜ÔÜÐQÓRÐRäˆD‹	€AØ
ˆqŒ&�S  Q¥�KÔ'Ø��EŠàŒ3ˆt‹9„}˜ Q¥œØˆQ��U‹à�‰�AÔØ�‰�A˜•E˜5Ö!r   c                ó@   € V ^8„  d   QhR\         R\        R\        RR/# )r   r}   Úpage_index_torh   r   N)r
   r   r   )r   s   "r   r   r   1  s0   € ÷ ñ Ü	ðäðô ðð 
ñ	r   c                ó"  € \        V4      ^,          ^ 8w  d   \        R4      hW8  d   \        R4      hVP                  V 4      ^,           pV\        V4      8  d4   W#,          V8:  d%   VP                  V4       VP                  V4       KA  R# R# )zö
Remove all entries in a number tree in a range after an entry.

See 7.9.7 "Number Trees".

Args:
    key: number key of the entry before the range
    page_index_to: The page index of the upper limit of the range
    nums: Nums array to modify

r   z/page_index_to must be greater or equal than keyN)ra   r2   rS   Úpop)r}   rƒ   rh   rj   s   &&& r   Únums_clear_ranger†   1  su   € ô  ˆ4ƒy�1…}˜ÔÜÐQÓRÐRØÔÜÐJÓKÐKà�
‰
�3‹˜!Õ€AØ
Œc�$‹iŒ-˜D�G }Ô4Ø�‰�ŒØ�‰�Žñ 5‰-r   c          	      óŠ   € V ^8„  d   QhR\         R\        R\        \        \         ,          \        \        ,          3,          /# )r   r}   rh   r   )r
   r   Útupler   r   )r   s   "r   r   r   L  s;   € ÷ ñ Ü	ðä
ðô Œ8”LÕ!¤8Ô,<Õ#=Ð=Õ>ñr   c                óÈ   € \        V4      ^,          ^ 8w  d   \        R4      hVP                  V 4      ^,           pV\        V4      8  d   W,          W^,           ,          3# R# )z™
Return the (key, value) pair of the entry after the given one.

See 7.9.7 "Number Trees".

Args:
    key: number key of the entry
    nums: Nums array

r   )NN)ra   r2   rS   )r}   rh   rj   s   && r   Ú	nums_nextrŠ   L  sV   € ô ˆ4ƒy�1…}˜ÔÜÐQÓRÐRà�
‰
�3‹˜!Õ€AØŒ3ˆt‹9„}Ø�w˜ �U�Ð#Ð#ØÐr   )Ú__doc__rH   Útypingr   r   r   Ú
_protocolsr   Ú_utilsr   Úgenericr   r   r	   r
   r   Úcollections.abcr   r3   rG   r<   rD   rM   rP   rn   r{   r�   r†   rŠ   rY   r   r   Ú<module>r‘      so   ðñ:óv ß 0Ñ 0å ,Ý "÷õ ÷ Ý(ð
 Ð ð  Ð õõ::õ@õ3õ;õ|JõZ"õ<÷6r   