HEX
Server: Apache
System: Linux srv1.prosuiteplus.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: prosuiteplus (1001)
PHP: 8.3.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pdfminer/__pycache__/pdfinterp.cpython-38.pyc
U

�R�]�e�@sddlZddlZddlmZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lmZddlm
Z
ddlmZdd
lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z"ddl#m$Z$ddl#m%Z%ddl#m&Z&ddl'Z'e�(e)�Z*Gd d!�d!e�Z+Gd"d#�d#e�Z,ed$�Z-ed%�Z.ed&�Z/ed'�Z0ed(�Z1Gd)d*�d*e2�Z3Gd+d,�d,e2�Z4Gd-d.�d.e2�Z5Gd/d0�d0e
�Z6Gd1d2�d2e2�Z7dS)3�N)�BytesIO�)�CMapDB)�CMap)�PSTypeError)�PSEOF)�	PSKeyword��literal_name)�keyword_name)�
PSStackParser)�LIT)�KWD)�settings)�PDFException)�	PDFStream)�	PDFObjRef)�resolve1)�
list_value)�
dict_value)�stream_value)�PDFFontError)�PDFType1Font)�PDFTrueTypeFont)�PDFType3Font)�
PDFCIDFont)�
PDFColorSpace)�PREDEFINED_COLORSPACE)�choplist)�mult_matrix)�MATRIX_IDENTITYc@seZdZdS)�PDFResourceErrorN��__name__�
__module__�__qualname__�r&r&�4/usr/lib/python3/dist-packages/pdfminer/pdfinterp.pyr!(sr!c@seZdZdS)�PDFInterpreterErrorNr"r&r&r&r'r(+sr(ZPDFZText�FontZFormZImagec@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�PDFTextStatecCs<d|_d|_d|_d|_d|_d|_d|_d|_|��dS)Nr�d)	�font�fontsize�	charspace�	wordspace�scaling�leading�render�rise�reset��selfr&r&r'�__init__:szPDFTextState.__init__cCs0d|j|j|j|j|j|j|j|j|j|j	f
S)Nz�<PDFTextState: font=%r, fontsize=%r, charspace=%r, wordspace=%r,  scaling=%r, leading=%r, render=%r, rise=%r,  matrix=%r, linematrix=%r>)
r,r-r.r/r0r1r2r3�matrix�
linematrixr5r&r&r'�__repr__Hs��zPDFTextState.__repr__cCsZt�}|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j	|_	|j
|_
|S�N)r*r,r-r.r/r0r1r2r3r8r9�r6�objr&r&r'�copyPszPDFTextState.copycCst|_d|_dS�N)rr)r r8r9r5r&r&r'r4^szPDFTextState.resetN)r#r$r%r7r:r>r4r&r&r&r'r*8sr*c@s$eZdZdd�Zdd�Zdd�ZdS)�PDFGraphicStatecCs:d|_d|_d|_d|_d|_d|_d|_d|_d|_dS�Nr�	�	linewidth�linecap�linejoin�
miterlimit�dash�intent�flatness�scolor�ncolorr5r&r&r'r7hszPDFGraphicState.__init__cCsRt�}|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j|_|j	|_	|Sr;)
r@rCrDrErFrGrHrIrJrKr<r&r&r'r>xszPDFGraphicState.copyc
Cs,d|j|j|j|j|j|j|j|j|jf	S)Nz�<PDFGraphicState: linewidth=%r, linecap=%r, linejoin=%r,  miterlimit=%r, dash=%r, intent=%r, flatness=%r,  stroking color=%r, non stroking color=%r>rBr5r&r&r'r:�s��zPDFGraphicState.__repr__N)r#r$r%r7r>r:r&r&r&r'r@fs
r@c@s4eZdZdZd
dd�Zdd�Zddd	�Zd
d�ZdS)�PDFResourceManagerz�Repository of shared resources.

    ResourceManager facilitates reuse of shared resources
    such as fonts and images so that large objects are not
    allocated multiple times.
    TcCs||_i|_dSr;)�caching�
_cached_fonts)r6rMr&r&r'r7�szPDFResourceManager.__init__cCs"|D]}|tkrq|tkrqqdSr;)�LITERAL_PDF�LITERAL_TEXT)r6Zprocs�procr&r&r'�get_procset�szPDFResourceManager.get_procsetFcCs4zt�|�WStjk
r.|r$�t�YSXdSr;)r�get_cmapZCMapNotFoundr)r6Zcmapname�strictr&r&r'rS�szPDFResourceManager.get_cmapcCsT|r||jkr|j|}�n4t�d||�tjrD|dtk	rDtd��d|krZt|d�}ntjrhtd��d}|dkr�t||�}n�|dkr�t	||�}n�|d	kr�t
||�}n�|d
kr�t||�}n||dk�rt|d�}|s�t
�t|d
���}dD]}||kr�t||�||<q�|�d|�}ntj�r.td|��t||�}|�rP|j�rP||j|<|S)Nz#get_font: create: objid=%r, spec=%rZTypezType is not /Font�SubtypezFont Subtype is not specified.�Type1)rVZMMType1ZTrueTypeZType3)ZCIDFontType0ZCIDFontType2ZType0ZDescendantFontsr)ZEncodingZ	ToUnicodezInvalid Font spec: %r)rN�log�infor�STRICT�LITERAL_FONTrr
rrrrr�AssertionErrorrr>r�get_fontrM)r6�objid�specr,�subtypeZdfontsZsubspec�kr&r&r'r\�sB


zPDFResourceManager.get_fontN)T)F)r#r$r%�__doc__r7rRrSr\r&r&r&r'rL�s


rLc@s^eZdZdd�Zdd�Zdd�Zdd�Zdd
d�Zdd
�Ze	d�Z
e	d�Ze	d	�Zdd�Z
dS)�PDFContentParsercCs||_d|_t�|d�dSrA)�streams�istreamrr7)r6rcr&r&r'r7�szPDFContentParser.__init__cCsP|jsL|jt|j�kr6t|j|j�}|jd7_ntd��t|���|_dS)NrzUnexpected EOF, file truncated?)�fprd�lenrcrrr�get_data)r6Zstrmr&r&r'�fillfp�szPDFContentParser.fillfpcCs|��t�||�dSr;)rhr�seek)r6�posr&r&r'ri�szPDFContentParser.seekcCsR|jt|j�krdS|��|j��|_|j�|j�|_|jr@qHd|_qd|_dSrA)	�charposrf�bufrhre�tellZbufpos�readZBUFSIZr5r&r&r'�fillbuf�szPDFContentParser.fillbuf�EIcCsZ|�|�d}d}|t|�k�r.|��|r�t�|j|j�}t�|�}||7}|jd7_t|�|krz|��rz|d7}n:|t|�kr�|tj	r�t�||�n||kr�|d7}nd}qz>|j�
|d|j�}||j|j|d�7}|d|_d}Wqtk
�r*||j|jd�7}t|j�|_YqXq|dt|�d�}t�
dd|�}||fS)Nr�rs(\x0d\x0a|[\x0d\x0a])$)rirfro�sixZ
indexbytesrlrkZint2byte�isspaceZPY3�index�
ValueError�re�sub)r6rj�target�i�data�c�jr&r&r'�get_inline_datas4


,

z PDFContentParser.get_inline_datacCs|j|���dSr;)Zadd_resultsZpopallr5r&r&r'�flush#szPDFContentParser.flushsBIsIDcCs�||jkr|�|d�n�||jkr�z�|�d�\}}t|�ddkrNtd|��tdd�td|�D��}|�|td��\}}t	||�}|�
||f�|�
||jf�Wq�tk
r�tj
r��Yq�Xn|�
||f�dS)NZinline�rz Invalid dictionary construct: %rcss|]\}}t|�|fVqdSr;r	)�.0r`�vr&r&r'�	<genexpr>4sz.PDFContentParser.do_keyword.<locals>.<genexpr>sID )�
KEYWORD_BIZ
start_type�
KEYWORD_IDZend_typerfr�dictrr}r�push�
KEYWORD_EIrrY)r6rj�token�_Zobjs�drzr=r&r&r'�
do_keyword+s"



zPDFContentParser.do_keywordN)rp)r#r$r%r7rhriror}r~rr�r�r�r�r&r&r&r'rb�s

rbc@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�Zd9d:�ZeZ d;d<�Z!d=d>�Z"d?d@�Z#dAdB�Z$dCdD�Z%dEdF�Z&dGdH�Z'dIdJ�Z(dKdL�Z)dMdN�Z*dOdP�Z+dQdR�Z,dSdT�Z-dUdV�Z.dWdX�Z/dYdZ�Z0d[d\�Z1d]d^�Z2d_d`�Z3dadb�Z4dcdd�Z5dedf�Z6dgdh�Z7didj�Z8dkdl�Z9dmdn�Z:dodp�Z;dqdr�Z<dsdt�Z=dudv�Z>dwdx�Z?dydz�Z@d{d|�ZAd}d~�ZBdd��ZCd�d��ZDd�d��ZEd�d��ZFd�d��ZGd�d��ZHd�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZReSfd�d��ZTd�d��ZUd�S)��PDFPageInterpretercCs||_||_dSr;)�rsrcmgr�device)r6r�r�r&r&r'r7EszPDFPageInterpreter.__init__cCs|�|j|j�Sr;)�	__class__r�r�r5r&r&r'�dupJszPDFPageInterpreter.dupcCs"||_i|_i|_t��|_|s$dSdd�}t�t|��D]�\}}t	�
d||�|dkr�t�t|��D]8\}}d}t|t�r�|j
}t|�}|j�||�|j|<qfq:|dkr�t�t|��D]\}}|t|��|j|<q�q:|dkr�|j�t|��q:|dkr:t�t|��D]\}	}
|
|j|	<�qq:dS)NcSs�t|t�rt|d�}nt|�}|dkrTt|t�rTdt|�krTt|t|d�d�S|dkr�t|t�r�dt|�kr�t|tt|d���St�|�SdS)NrZICCBasedrr�NZDeviceN)	�
isinstance�listr
rfrrrr�get)r^�namer&r&r'�get_colorspaceWs
z9PDFPageInterpreter.init_resources.<locals>.get_colorspacezResource: %r: %rr)Z
ColorSpaceZProcSetZXObject)�	resources�fontmap�xobjmaprr>�csmaprrZ	iteritemsrrW�debugr�rr]r�r\rrRr)r6r�r�r`r��fontidr^r]Zcsid�xobjidZxobjstrmr&r&r'�init_resourcesOs2

z!PDFPageInterpreter.init_resourcescCsfg|_||_|j�|j�t�|_t�|_g|_g|_	d|_
|_|jrbt
�t
�|j��|_
|_dSr;)�gstack�ctmr��set_ctmr*�	textstater@�graphicstate�curpath�argstack�scs�ncsr�rr�nextZ
itervalues)r6r�r&r&r'�
init_statewszPDFPageInterpreter.init_statecCs|j�|�dSr;)r��appendr<r&r&r'r��szPDFPageInterpreter.pushcCs2|dkrgS|j|d�}|jd|�|_|SrA)r�)r6�n�xr&r&r'�pop�s
zPDFPageInterpreter.popcCs|j|j��|j��fSr;)r�r�r>r�r5r&r&r'�get_current_state�sz$PDFPageInterpreter.get_current_statecCs"|\|_|_|_|j�|j�dSr;)r�r�r�r�r�)r6�stater&r&r'�set_current_state�sz$PDFPageInterpreter.set_current_statecCs|j�|���dSr;)r�r�r�r5r&r&r'�do_q�szPDFPageInterpreter.do_qcCs|jr|�|j���dSr;)r�r�r�r5r&r&r'�do_Q�szPDFPageInterpreter.do_QcCs,t||||||f|j�|_|j�|j�dSr;)rr�r�r�)r6Za1Zb1Zc1Zd1Ze1�f1r&r&r'�do_cm�szPDFPageInterpreter.do_cmcCs||j_dSr;)r�rC)r6rCr&r&r'�do_w�szPDFPageInterpreter.do_wcCs||j_dSr;)r�rD)r6rDr&r&r'�do_J�szPDFPageInterpreter.do_JcCs||j_dSr;)r�rE)r6rEr&r&r'�do_j�szPDFPageInterpreter.do_jcCs||j_dSr;)r�rF)r6rFr&r&r'�do_M�szPDFPageInterpreter.do_McCs||f|j_dSr;)r�rG)r6rGZphaser&r&r'�do_d�szPDFPageInterpreter.do_dcCs||j_dSr;)r�rH)r6rHr&r&r'�do_ri�szPDFPageInterpreter.do_ricCs||j_dSr;)r�rI)r6rIr&r&r'�do_i�szPDFPageInterpreter.do_icCsdSr;r&�r6r�r&r&r'�do_gs�szPDFPageInterpreter.do_gscCs|j�d||f�dS)N�m�r�r��r6r��yr&r&r'�do_m�szPDFPageInterpreter.do_mcCs|j�d||f�dS)N�lr�r�r&r&r'�do_l�szPDFPageInterpreter.do_lc	Cs|j�d||||||f�dS)Nr{r�)r6�x1�y1�x2�y2�x3�y3r&r&r'�do_c�szPDFPageInterpreter.do_ccCs|j�d||||f�dS)Nr�r�)r6r�r�r�r�r&r&r'�do_v�szPDFPageInterpreter.do_vcCs|j�d||||f�dS)Nr�r�)r6r�r�r�r�r&r&r'�do_y�szPDFPageInterpreter.do_ycCs|j�d�dS)N��hr�r5r&r&r'�do_h�szPDFPageInterpreter.do_hcCsh|j�d||f�|j�d|||f�|j�d||||f�|j�d|||f�|j�d�dS)Nr�r�r�r�)r6r�r��wr�r&r&r'�do_re�szPDFPageInterpreter.do_recCs"|j�|jddd|j�g|_dS�NTF�r�Z
paint_pathr�r�r5r&r&r'�do_S�szPDFPageInterpreter.do_ScCs|��|��dSr;)r�r�r5r&r&r'�do_sszPDFPageInterpreter.do_scCs"|j�|jddd|j�g|_dS�NFTr�r5r&r&r'�do_fszPDFPageInterpreter.do_fcCs"|j�|jddd|j�g|_dSr�r�r5r&r&r'�do_f_aszPDFPageInterpreter.do_f_acCs"|j�|jddd|j�g|_dSr�r�r5r&r&r'�do_BszPDFPageInterpreter.do_BcCs"|j�|jddd|j�g|_dS)NTr�r5r&r&r'�do_B_aszPDFPageInterpreter.do_B_acCs|��|��dSr;)r�r�r5r&r&r'�do_b!szPDFPageInterpreter.do_bcCs|��|��dSr;)r�r�r5r&r&r'�do_b_a'szPDFPageInterpreter.do_b_acCs
g|_dSr;)r�r5r&r&r'�do_n-szPDFPageInterpreter.do_ncCsdSr;r&r5r&r&r'�do_W2szPDFPageInterpreter.do_WcCsdSr;r&r5r&r&r'�do_W_a6szPDFPageInterpreter.do_W_acCs@z|jt|�|_Wn&tk
r:tjr6td|��YnXdS�NzUndefined ColorSpace: %r)r�r
r��KeyErrorrrYr(r�r&r&r'�do_CS:szPDFPageInterpreter.do_CScCs@z|jt|�|_Wn&tk
r:tjr6td|��YnXdSr�)r�r
r�r�rrYr(r�r&r&r'�do_csCszPDFPageInterpreter.do_cscCs||j_dSr;�r�rJ�r6Zgrayr&r&r'�do_GLszPDFPageInterpreter.do_GcCs||j_dSr;�r�rKr�r&r&r'�do_gRszPDFPageInterpreter.do_gcCs|||f|j_dSr;r��r6�r�g�br&r&r'�do_RGXszPDFPageInterpreter.do_RGcCs|||f|j_dSr;r�r�r&r&r'�do_rg^szPDFPageInterpreter.do_rgcCs||||f|j_dSr;r��r6r{r�r�r`r&r&r'�do_KdszPDFPageInterpreter.do_KcCs||||f|j_dSr;r�r�r&r&r'�do_kjszPDFPageInterpreter.do_kcCs4|jr|jj}ntjrtd��d}|�|�|j_dS�NzNo colorspace specified!r)r��ncomponentsrrYr(r�r�rJ�r6r�r&r&r'�do_SCNps
zPDFPageInterpreter.do_SCNcCs4|jr|jj}ntjrtd��d}|�|�|j_dSr�)r�r�rrYr(r�r�rKr�r&r&r'�do_scnzs
zPDFPageInterpreter.do_scncCs|��dSr;)r�r5r&r&r'�do_SC�szPDFPageInterpreter.do_SCcCs|��dSr;)r�r5r&r&r'�do_sc�szPDFPageInterpreter.do_sccCsdSr;r&r�r&r&r'�do_sh�szPDFPageInterpreter.do_shcCs|j��dSr;)r�r4r5r&r&r'�do_BT�s
zPDFPageInterpreter.do_BTcCsdSr;r&r5r&r&r'�do_ET�szPDFPageInterpreter.do_ETcCsdSr;r&r5r&r&r'�do_BX�szPDFPageInterpreter.do_BXcCsdSr;r&r5r&r&r'�do_EX�szPDFPageInterpreter.do_EXcCs|j�|�dSr;�r�Zdo_tag�r6�tagr&r&r'�do_MP�szPDFPageInterpreter.do_MPcCs|j�||�dSr;r��r6rZpropsr&r&r'�do_DP�szPDFPageInterpreter.do_DPcCs|j�|�dSr;�r�Z	begin_tagrr&r&r'�do_BMC�szPDFPageInterpreter.do_BMCcCs|j�||�dSr;rrr&r&r'�do_BDC�szPDFPageInterpreter.do_BDCcCs|j��dSr;)r�Zend_tagr5r&r&r'�do_EMC�s
zPDFPageInterpreter.do_EMCcCs||j_dSr;)r�r.�r6Zspacer&r&r'�do_Tc�szPDFPageInterpreter.do_TccCs||j_dSr;)r�r/r	r&r&r'�do_Tw�szPDFPageInterpreter.do_TwcCs||j_dSr;)r�r0)r6Zscaler&r&r'�do_Tz�szPDFPageInterpreter.do_TzcCs||j_dSr;)r�r1)r6r1r&r&r'�do_TL�s
zPDFPageInterpreter.do_TLcCs\z|jt|�|j_Wn8tk
rNtjr8td|��|j�	di�|j_YnX||j_
dS)NzUndefined Font id: %r)r�r
r�r,r�rrYr(r�r\r-)r6r�r-r&r&r'�do_Tf�szPDFPageInterpreter.do_TfcCs||j_dSr;)r�r2)r6r2r&r&r'�do_Tr�szPDFPageInterpreter.do_TrcCs||j_dSr;)r�r3)r6r3r&r&r'�do_Ts�szPDFPageInterpreter.do_Tsc	CsT|jj\}}}}}}||||||||||||||f|j_d|j_dSr?�r�r8r9�	r6ZtxZty�ar�r{r��e�fr&r&r'�do_Td�s4zPDFPageInterpreter.do_Tdc	Cs\|jj\}}}}}}||||||||||||||f|j_||j_d|j_dSr?�r�r8r1r9rr&r&r'�do_TD�s
4zPDFPageInterpreter.do_TDcCs ||||||f|j_d|j_dSr?r�r6rr�r{r�rrr&r&r'�do_Tm�szPDFPageInterpreter.do_TmcCsL|jj\}}}}}}|||||jj|||jj||f|j_d|j_dSr?rrr&r&r'�do_T_a�s,zPDFPageInterpreter.do_T_acCs>|jjdkrtjrtd��dS|j�|j||j|j�	��dS)NzNo font specified!)
r�r,rrYr(r�Z
render_stringr�r�r>)r6�seqr&r&r'�do_TJ�szPDFPageInterpreter.do_TJcCs|�|g�dSr;)r�r6�sr&r&r'�do_TjszPDFPageInterpreter.do_TjcCs|��|�|g�dSr;)rrrr&r&r'�do__q
szPDFPageInterpreter.do__qcCs$|�|�|�|�|�|g�dSr;)rr
r)r6ZawZacrr&r&r'�do__ws

zPDFPageInterpreter.do__wcCsdSr;r&r5r&r&r'�do_BIszPDFPageInterpreter.do_BIcCsdSr;r&r5r&r&r'�do_IDszPDFPageInterpreter.do_IDcCsJd|krFd|krFtt|��}|j�|dt�|j�||�|j�|�dS)N�W�H�rrrr)�str�idr��begin_figurer �render_image�
end_figure)r6r=Ziobjidr&r&r'�do_EI szPDFPageInterpreter.do_EIc	Cs4t|�}zt|j|�}Wn(tk
rBtjr<td|��YdSXt�d|�|�	d�}|t
kr�d|kr�|��}t|d�}t|�	dt
��}|�	d�}|r�t|�n|j��}|j�|||�|j||gt||j�d�|j�|�nJ|tk�r0d|k�r0d	|k�r0|j�|d
t
�|j�||�|j�|�ndS)NzUndefined xobject id: %rzProcessing xobj: %rrUZBBoxZMatrixZ	Resources�r�ZWidthZHeightr')r
rr�r�rrYr(rWrXr��LITERAL_FORMr�rr rr�r>r�r*�render_contentsrr�r,�
LITERAL_IMAGEr+)	r6r�Zxobjr_ZinterpreterZbboxr8Zxobjresr�r&r&r'�do_Do)s.

zPDFPageInterpreter.do_DocCs�t�d|�|j\}}}}|jdkr8dddd||f}nN|jdkrTdddd||f}n2|jdkrrdddd||f}ndddd||f}|j�||�|j|j|j|d�|j�	|�dS)	NzProcessing page: %r�Zr���r�ir.)
rWrXZmediabox�rotater�Z
begin_pager0r��contentsZend_page)r6ZpageZx0Zy0r�r�r�r&r&r'�process_pageHs


zPDFPageInterpreter.process_pagecCs6t�d|||�|�|�|�|�|�t|��dS)Nz1render_contents: resources=%r, streams=%r, ctm=%r)rWrXr�r��executer)r6r�rcr�r&r&r'r0[s�

z"PDFPageInterpreter.render_contentsc
Cszt|�}Wntk
r"YdSXz|��\}}Wntk
rNY�qYnXt|t��rt|�}d|�dd��dd��dd�}t||�r�t||�}t	�
|�jd}|r�|�|�}	t
�d	||	�t|	�|kr�||	�nt
�d
|�|�ntj�rtd|��q$|�|�q$dS)Nzdo_%s�*Z_a�"Z_w�'Z_qrzexec: %s %rzexec: %szUnknown operator: %r)rbrZ
nextobjectr�rr�replace�hasattr�getattrrrZget_function_code�co_argcountr�rWr�rfrrYr(r�)
r6rc�parserr�r=r��method�func�nargs�argsr&r&r'r9cs2 



zPDFPageInterpreter.executeN)Vr#r$r%r7r�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�Zdo_Fr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrrr
rrr
rrrrrrrrr r!r"r#r$r-r2r8r r0r9r&r&r&r'r�Cs�(			

	
	r�)8rvZlogging�iorZcmapdbrrZpsparserrrrr
rrr
r�rZpdftypesrrrrrrrZpdffontrrrrrZpdfcolorrrZutilsrrr rrZ	getLoggerr#rWr!r(rOrPrZr/r1�objectr*r@rLrbr�r&r&r&r'�<module>sX
.*Pc