
    Fg                        S SK r S SKrS SKJrJr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Jr  S SKJrJr  S SKJr  S SKJrJrJrJr  S SKJr  S S	KJr  \R@                  " \!5      r"\" S
5      r#\" S5      r$ " S S5      r%g)    N)	AnyBinaryIO	ContainerDictIteratorListOptionalSetTuple)settings)PDFDocumentPDFNoPageLabelsPDFTextExtractionNotAllowed)PDFObjectNotFoundPDFValueError)	PDFParser)
dict_value	int_value
list_valueresolve1)LIT)
parse_rectPagePagesc                       \ rS rSrSrS\S\S\S\\   SS4
S	 jr	S\4S
 jr
1 Skr\S\S\S    4S j5       r\     SS\S\\\      S\S\S\S\S\S    4S jj5       rSrg)PDFPage   a2  An object that holds the information about a page.

A PDFPage object is merely a convenience class that has a set
of keys and values, which describe the properties of a page
and point to its contents.

Attributes
----------
  doc: a PDFDocument object.
  pageid: any Python object that can uniquely identify the page.
  attrs: a dictionary of page attributes.
  contents: a list of PDFStream objects that represents the page content.
  lastmod: the last modified time of the page.
  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).
  annots: the page annotations.
  beads: a chain that represents natural reading order.
  label: the page's label (typically, the logical page number).

docpageidattrslabelreturnNc                    Xl         X l        SU l        [        U5      U l        X@l        [        U R                  R                  S5      5      U l        [        U R                  R                  S[        5       5      5      U l
        U R                  S    Vs/ s H  n[        U5      PM     nn[        [        U5      5      U l        U R                  U l        SU R                  ;   a'   [        [        U R                  S   5      5      U l        [        U R                  R                  SS5      5      S-   S-  U l        U R                  R                  S5      U l        U R                  R                  S	5      U l        S
U R                  ;   a  [        U R                  S
   5      nO/ n['        U[(        5      (       d  U/nXpl        gs  snf ! [         a     Nf = f)zInitialize a page object.

doc: a PDFDocument object.
pageid: any Python object that can uniquely identify the page.
attrs: a dictionary of page attributes.
label: page label string.
r   LastModified	ResourcesMediaBoxCropBoxRotateih  AnnotsBContentsN)r   r   pagenor   r    r!   r   getlastmoddict	resourcesr   mediaboxcropboxr   r   rotateannotsbeads
isinstancelistcontents)selfr   r   r    r!   mediabox_parammediabox_paramsr8   s           _/Users/admin/workspace/ai/PDFMathTranslate/myenv/lib/python3.13/site-packages/pdf2zh/pdfpage.py__init__PDFPage.__init__0   s{    &



~ >?/7JJNN;/0
 <@::j;Q&
;QH^$;Q 	 &
 #8O#<=}}

")(4::i3H*IJ !!!<=CsJjjnnX.ZZ^^C(
#

: 67HH(D)) zH&.)&
 ! s   G(&G 
GGc                 @    SU R                   < SU R                  < S3$ )Nz<PDFPage: Resources=z, MediaBox=>)r0   r1   )r9   s    r<   __repr__PDFPage.__repr__]   s"    %dnn%7{4==BSSTUU    >   r(   r'   r&   r%   documentc              #   <  ^ ^^	#     S
S[         S[        [        [         4   S[        [        [               S[
        [        [        [        [         [        [         [         4   4   4      4U U	U4S jjjm	 TR                  5       nSnSTR                  ;   aB  T	" TR                  S   TR                  5      nU H  u  pVT " TXV[        U5      5      v   SnM     U(       d  TR                   Hr  nUR                  5        H[  n TR!                  U5      n[#        U[$        5      (       a1  UR'                  S	5      [(        L a  T " TXX[        U5      5      v   MY  M[  M]     Mt     g g ! [         a    [        R                  " S 5      n GNf = f! [*         a     M  f = f7f)Nobjparentvisitedr"   c              3     >#    [        U [        5      (       a+  U n[        TR                  U5      5      R	                  5       nO%U R
                  n[        U 5      R	                  5       nUc
  [        5       nX2;   a  g UR                  U5        UR                  5        H"  u  pVUT	R                  ;   d  M  XT;  d  M  XdU'   M$     UR                  S5      nUc&  [        R                  (       d  UR                  S5      nU[        L a-  SU;   a'  [        US   5       H  nT
" XU5       S h  vN   M     g U[        L a  X44v   g g  N7f)NTypetypeKids)r6   intr   getobjcopyobjidsetadditemsINHERITABLE_ATTRSr-   r   STRICTLITERAL_PAGESr   LITERAL_PAGE)rF   rG   rH   	object_idobject_propertieskvobject_typechildclsdepth_first_searchrD   s            r<   r_   0PDFPage.create_pages.<locals>.depth_first_searchd   s'    
 #s##	$.xy/I$J$O$O$Q!  II	$.sO$8$8$:! %#KK	"---!2L+,a( ' ,//7K"8??/33F;m+:K0K'(9&(ABE1%GTTT C , 44 - Us   B-E4E;A.E)E*EFr   TrJ   )N)r   r   strr	   r
   r   r   rM   get_page_labelsr   	itertoolsrepeatcatalognextxrefs
get_objidsrN   r6   r/   r-   rW   r   )
r^   rD   page_labelspagesobjectsrP   treexrefrF   r_   s
   ``       @r<   create_pagesPDFPage.create_pagesb   s~    
 +/$	5$	5cN$	5 c#h'$	5 eCc4S>&9!::;<	$	5 $	5L	13;3K3K3MK h&&&()9)9')BHDTDTUG&(Ek1BCC  '  !__.E&ooe4%c400SWWV_5T"%hD<M"NN 6U0 / '   	1#**40K	1" - sP   A/F5E$ A=FAFF$ FFFF
FFFFfppagenosmaxpagespasswordcachingcheck_extractablec              #   V  #    [        U5      n[        XtUS9nUR                  (       d1  U(       a  SU-  n	[        U	5      eSU-  n
[        R                  U
5        [        U R                  U5      5       H0  u  pXl        U(       a  X;  a  M  Uv   U(       d  M&  X;S-   ::  d  M0    g    g 7f)N)rs   rt   z"Text extraction is not allowed: %rzThe PDF %r contains a metadata field indicating that it should not allow text extraction. Ignoring this field and proceeding. Use the check_extractable if you want to raise an error in this case   )	r   r   is_extractabler   logwarning	enumeratern   r,   )r^   rp   rq   rr   rs   rt   ru   parserr   	error_msgwarning_msgr,   pages                r<   	get_pagesPDFPage.get_pages   s      2&WE !! @2E	1)<<A DF	F  K(%c&6&6s&;<LFKF1JxH
2 =s   BB)B)$B))r4   r    r5   r8   r2   r   r!   r.   r1   r   r,   r0   r3   )Nr    TF)__name__
__module____qualname____firstlineno____doc__r   objectr	   ra   r=   rA   rT   classmethodr   rn   r   r   rM   boolr   __static_attributes__ rC   r<   r   r      s    .+/+/ +/ 	+/
 }+/ 
+/ZV# V G;K ;HY4G ; ;z  -1"'## )C.)# 	#
 # #  # 
)	# #rC   r   )&rc   loggingtypingr   r   r   r   r   r   r	   r
   r   pdf2zhr   pdf2zh.pdfdocumentr   r   r   pdf2zh.pdfexceptionsr   r   pdf2zh.pdfparserr   pdf2zh.pdftypesr   r   r   r   pdf2zh.psparserr   pdf2zh.utilsr   	getLoggerr   ry   rW   rV   r   r   rC   r<   <module>r      sf      W W W  
 B & G G  #! 6{Gl lrC   