%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/reportlab/pdfbase/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/reportlab/pdfbase/__pycache__/pdfdoc.cpython-312.pyc

�

��e0`�� �dZdZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZm
Z
mZmZmZmZmZmZmZmZddlmZmZmZmZdd	lmZdd
lmZddlmZGd�d
e �Z!dZ"dZ#dZ$dZ%dZ&dZ'e(d��Z)d�Z*d�d�Z+d�Z,e,Z-Gd�d�Z.Gd�d�Z/Gd�de/�Z0Gd�d e/�Z1d!Z2d"Z3d#Z4Gd$�d%e/�Z5d&�Z6ddl7Z7e7jpd'�Z9[7d(�Z:d)�Z;Gd*�d+e/�Z<e=d,�e=d-�fd.�Z>Gd/�d0e/�Z?Gd1�d2�Z@d3�ZAGd4�d5e?�ZBGd6�d7eB�ZCGd8�d9�ZDeD�ZEGd:�d;�ZFeF�ZGGd<�d=e/�ZHd�d>�ZId?ZJGd@�dAe/�ZKGdB�dCeK�ZLGdD�dEe/�ZMGdF�dGe/�ZNGdH�dIe/�ZOGdJ�dKe/�ZPGdL�dMe/�ZQGdN�dOe/�ZRGdP�dQe/�ZSGdR�dSeS�ZTGdT�dUeS�ZUGdV�dWe �ZVGdX�dYeS�ZWGdZ�d[eS�ZXd\�ZYd]ZZGd^�d_e/�Z[Gd`�dae/�Z\Gdb�dce/�Z]d�dd�Z^deZ_Gdf�dge/�Z`Gdh�die/�ZaGdj�dkea�ZbGdl�dmea�ZcGdn�doea�ZdGdp�dqed�Zedr�ZfGds�dte/�ZgGdu�dve/�ZhGdw�dxe/�ZiGdy�dze/�ZjGd{�d|e/�ZkGd}�d~ek�ZlGd�d�e/�ZmGd��d�em�ZnGd��d�e/�ZoGd��d�eo�ZpGd��d�e/�ZqGd��d�e/�ZrGd��d�e/�ZsGd��d�es�ZtGd��d�e/�ZuGd��d�e/�Zvd�d�d�d��ZwGd��d�e/�ZxGd��d��ZyGd��d�e/�ZzGd��d�ez�Z{Gd��d�ez�Z|Gd��d�e/�Z}Gd��d�e}�Z~Gd��d�e}�ZGd��d�e}�Z�e�d�k(r	e�d��yy)�z3.6.0a_
The module pdfdoc.py handles the 'outer structure' of PDF documents, ensuring that
all objects are properly cross-referenced and indexed to the nearest byte.  The
'inner structure' - the page descriptions - are presumed to be generated before
each page is saved.
pdfgen.py calls this and provides a 'canvas' object to handle page marking operators.
piddlePDF calls pdfgen and offers a high-level interface.

The classes within this generally mirror structures in the PDF file
and are not part of any public interface.  Instead, canvas and font
classes are made available elsewhere for users to manipulate.
�N)�OrderedDict)�pdfutils)�	rl_config)
�
open_for_read�makeFileName�isSeq�isBytes�	isUnicode�	_digester�isStr�bytestr�annotateException�	TimeStamp)�	escapePDF�fp_str�asciiBase85Encode�asciiBase85Decode)�
pdfmetrics)�md5)�stderrc��eZdZy)�PDFErrorN��__name__�
__module__�__qualname__���:/usr/lib/python3/dist-packages/reportlab/pdfbase/pdfdoc.pyrr���rr�__InternalName__�__RefOnly__�__Comment__�
BasicFonts�Pages)��)r&�)�transparencyc�H�t|t�r|jd�S|S)N�	extpdfdoc)�
isinstance�str�encode)�xs r�	pdfdocEncr05s��$.�q��$5�1�8�8�K� �<�1�<rc��t|t�r�|s0t|t�r |j	|�j|�S|j|�}tjs;tjr+t|t�rtd|jz�|z}|St|�ttfvrtt|��St|�r|St!|�rt|�Stt#|��S)z�Indirection step for formatting.
       Ensures that document parameters alter behaviour
       of formatting for all elements.
    z%% %s
)r,�	PDFObject�hasattrr"�	Reference�formatr�	invariant�pdfCommentsr#r0�type�float�intrr	r
r-)�element�document�toplevel�fs    rr5r58s���
�'�)�$��G�G�[�9��%�%�g�.�5�5�h�?�?����x�(�A��&�&�9�+@�+@�W�W�Va�Eb��i�'�*=�*=�=�>�q�@���H�	
�g��5�#�,�	&�����)�)�	��	���	�7�	���!�!���W��&�&rc��d|zS)Nz
FormXob.%sr)�externalnames r�xObjectNamerARs
���,�&�&rc�$�eZdZd�Zd�Zd�Zd�Zy)�NoEncryptionc��|S)zencode a string, stream, textr)�self�ts  rr.zNoEncryption.encodeZs���rc��y�Nr�rEr<s  r�preparezNoEncryption.prepare]���rc��yrHr)rE�objnum�versions   r�registerzNoEncryption.register`rKrc��yrHr�rEs r�infozNoEncryption.infocs��rN)rrrr.rJrOrRrrrrCrCYs���
�
�rrCc��eZdZy)r2Nrrrrr2r2gr rr2c��eZdZdZe�Zy)�DummyDocz'used to bypass encryption when requiredN)rrr�__doc__rC�encryptrrrrUrUjs��-��n�GrrUc��eZdZdZe�Zdejejde	dfd�Z
d�Zd�Zd�Z
d�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d�Z"d�Z#d�Z$d�Z%d�Z&d$d �Z'd!�Z(d"�Z)d%d#�Z*y)&�PDFDocumentNrc�f�d|_d|_d|_d|_d|_|�t
j|_n||_|j|�||_t�x}|_
|jd�t|j�|_
|jj}t|�}|jt!|��i|_i|_i|_i|_t+�x}x|_|_t1�x}	|_|	|_|r|nt
j4}|rt7|�|_|r
t;�n	t=�x|_x|_ |_ tC�|_"i|_#tIi�}
d|
_%|jM|
tN�g|_(y)Nrr&sa reportlab documentzThe standard fonts dictionary))�_ID�
objectcounter�shadingCounter�inObject�pageCounterrr6�setCompression�_pdfVersionr�	signature�updater�
_timeStamprF�asciir
�idToObjectNumberAndVersion�
idToObject�
idToOffset�
numberToId�
PDFCatalog�Catalog�_catalog�PDFPagesr%�documentLang�	PDFString�Lang�PDFOutlines0�PDFOutlines�outline�Outlines�PDFInforR�fontMapping�
PDFDictionaryr#r4r$�delayedFonts)rE�dummyoutline�compressionr6�filename�
pdfVersion�lang�sig�cat�pages�DDs           r�__init__zPDFDocument.__init__ssl�������������
������&�0�0�D�N�&�D�N����K�(�%���"�u�$��d�n��
�
�*�+�#�D�N�N�3����o�o�����C�j���
�
�7�3�<� �*,��'����������-7�\�9��9�d�l�T�]�%�Z�'���
���	��t��!7�!7��� ���C�H�HT�l�n�Ze�Zg�g���g�t�}�s�|��I��	����
�2�
��8������r�:�&���rc��||_yrH�rz�rE�onoffs  rr`zPDFDocument.setCompression�s
�� ��rc�V�|D]$}t|jt|�|_�&y)zREnsure that the pdf version is greater than or equal to that specified by the keysN)�maxra�PDF_SUPPORT_VERSION)rE�keys�ks   r�ensureMinPdfVersionzPDFDocument.ensureMinPdfVersion�s.���	M�A�"�4�#3�#3�5H��5K�L�D��	Mrc�f�|jry|jjt|��y)z add information to the signatureN)r[rbrcr
)rE�things  r�updateSignaturezPDFDocument.updateSignature�s!���8�8�V������g�e�n�-rc���|jr|jS|jj�}t�}t	|d��j|�}d|z|zdz|_|jS)z<A unique fingerprint for the file (unless in invariant mode)�raw)�encs
[sJ]
% ReportLab generated PDF document -- digest (http://www.reportlab.com)
)r[rb�digestrU�PDFTextr5)rEr��doc�IDss    r�IDzPDFDocument.ID�s`���8�8��8�8�O����&�&�(���j���f��'�.�.�s�3���3�J�s�N�#r�r����x�x�rc���t|dd�r"td|jjz��d|_tt|dd�d�rbd}|}t|dd�}t
|t�rd	|z}n/t|�s$d
|jjt|�fz}t|�}n<t|�rd}t|�}t|d�}ntd
t|�z��|j|�}t|�r|j!d�}|j#|�|r1|j%�ddl}|j(dk(rddlm}||�t|dd�rt/d|���yy)N�_savedToFileFz)class %s instances can only be saved onceT�write�__call__r�namez
<os fd:%d>z<%s@0X%8.8X>r&�wbz#Cannot use %s as a filename or file�latin1�mac)�markfilename�
_verbosityzsaved )�getattr�RuntimeError�	__class__rr�r3r,r:r�idr�open�	TypeError�repr�
GetPDFDatar
r.r��close�osr��reportlab.lib.utilsr��print)rEr{�canvas�myfiler>�datar�r�s        r�
SaveToFilezPDFDocument.SaveToFile�sA���4��u�-��J�T�^�^�Md�Md�d�e�e� ����7�8�W�T�2�:�>��F��A��q���-�H��(�3�'�'��1���8�_�)�Q�[�[�-A�-A�"�Q�%�,H�H��#�H�-�H�
�8�_��F�#�H�-�H��X�t�$�A��A�D��N�R�S�S����v�&���T�?��;�;�x�(�D�	����
��
�G�G�I���w�w��~�<��X�&��6�,�t�,�e�(�4L�.M�,rc���|jD]}|j|��|j|j_|jj	|j
�|j
|j�|j
|j�|jj||�|jjdkrd|j_|j�S�Nr)rx�
addObjectsr6rRr�rbr4rkrtrJ�readyr5)rEr��fnts   rr�zPDFDocument.GetPDFData�s����$�$�	!�C��N�N�4� �	!�#�n�n��	�	���	�	������(�	
���t�|�|�$����t�y�y�!��
�
���d�F�+��=�=���q� �$(�D�L�L�!��{�{�}�rc�z�|j�(|jdk(rytd|jz��d|_y)zXspecify the current object as a page (enables reference binding and other page features)N�pagez%can't go in page already in object %s)r^�
ValueErrorrQs r�inPagezPDFDocument.inPage�s6���=�=�$��}�}�f�$�f��D�t�}�}�T�U�U���
rc��d|_y)zBspecify that we are in a form xobject (disable page features, etc)�formN)r^rQs r�inFormzPDFDocument.inForm�s��
��
rc��|j}||vr||S	tj|�}|jrt	dt|�z��|j
|�||S#t$rt	dt|�z��wxYw)Nz1getInternalFontName(%s) called for a dynamic fontzFont %s not known!)rvr�getFont�_dynamicFontrr�r��KeyError)rE�
psfontname�fm�fontObjs    r�getInternalFontNamezPDFDocument.getInternalFontName�s���
�
�
������j�>�!�
H�$�,�,�Z�8���'�'�"�#V�Y]�^h�Yi�#i�j�j��"�"�4�(��*�~�%���
H��3�d�:�6F�F�G�G�
H�s�A
A%�%!Bc�2�dt|j�zS)N�Page)r�r_rQs r�thisPageNamezPDFDocument.thisPageNames���d�4�+�+�,�,�,rc�4�t|j��SrH)�PDFObjectReferencer�rQs r�thisPageRefzPDFDocument.thisPageRefs��!�$�"3�"3�"5�6�6rc��|j�}|j||�|jj|�|xjdz
c_d|_y)Nr&)r�r4r%�addPager_r^)rEr�r�s   rr�zPDFDocument.addPagesH��� � �"�����t�T�"��
�
���4� ����A�����
rc��|jdk7r|j�|j|t|��d|_y)zadd a Form XObject.r�N)r^r�r4rA)rEr�r�s   r�addFormzPDFDocument.addForms3���=�=�F�"��K�K�M����t�[��.�/���
rc��d|zS)NzAnnot.%sr)rEr@s  r�annotationNamezPDFDocument.annotationName#s
���,�&�&rc�F�|j||j|��yrH)r4r�)rEr��
annotations   r�
addAnnotationzPDFDocument.addAnnotation&s�����z�4�#6�#6�t�#<�=rc�:�|j|�}t|�SrH)r�r��rEr��internalnames   r�
refAnnotationzPDFDocument.refAnnotation)s���*�*�4�0��!�,�/�/rc�r�d|jz}|j||�|xjdz
c_|S)NzSh%dr&)r]r4)rE�shadingr�s   r�
addShadingzPDFDocument.addShading-s6����,�,�,��	
�����	&�	
�	�	��	!�	��rc�v�|j}|s�|jdk(r!|jdk(r|jdk(rd}n�|jdk(r!|jdk(r|jdk(rd}n_|jdk(r!|jdk(r|jdk(rd}n/|jdk(r |jdk(r|jdk(rd}|std|z��|j
|��}t|�dd}||jvr+t|�j�}|j||�||fS)	Nr�BLACK�CYAN�MAGENTA�YELLOWz&CMYK colour %r used without a spotName)�spotNamer&)r��cyan�magenta�yellow�blackr��clone�PDFNamerg�PDFSeparationCMYKColor�valuer4)rE�cmyk�snamer��seps     r�addColorzPDFDocument.addColor3s	���
�
����y�y�!�|����a��D�K�K��N������Q��4�<�<��?�t�{�{�A�~������A��$�*�*�a�-�D�K�K��N�!�����A��$�,�,��/�d�j�j�!�m� ��� �!I�D�!P�Q�Q��z�z�U�z�3���u�~�a�b�!���t���&�(��.�4�4�6�C��N�N�3�t�$��E�z�rc�N�|�d|j_y||j_y)�embeds in PDF fileN�(anonymous))rR�title)rEr�s  r�setTitlezPDFDocument.setTitleHs���=�+�D�I�I�O�#�D�I�I�Orc�N�|�d|j_y||j_y)zembedded in PDF fileNr�)rR�author)rEr�s  r�	setAuthorzPDFDocument.setAuthorOs!���>�,�D�I�I��%�D�I�I�rc�N�|�d|j_y||j_y�r�Nz
(unspecified))rR�subject)rEr�s  r�
setSubjectzPDFDocument.setSubjectWs!���?� /�D�I�I�� '�D�I�I�rc�N�|�d|j_y||j_yr�)rR�creator)rEr�s  r�
setCreatorzPDFDocument.setCreator`s���?� /�D�I�I�� '�D�I�I�rc�V�|�t|j_y||j_y)r�N)�_default_producerrR�producer)rEr�s  r�setProducerzPDFDocument.setProducergs ����!2�D�I�I��!)�D�I�I�rc�N�|�d|j_y||j_y)z/embeds a string containing keywords in PDF fileN�)rR�keywords)rErs  r�setKeywordszPDFDocument.setKeywordsns"����!#�D�I�I��!)�D�I�I�rc�&�||j_yrH)rR�_dateFormatter)rE�
dateFormatters  r�setDateFormatterzPDFDocument.setDateFormatterws��#0��	�	� rc���t|jj��}ddlm}|j
D]}||vs�|j
|��|j�|S)Nr)�	_fontdata)�listrvr��reportlab.pdfbaser
�
standardFonts�append�sort)rE�	fontnamesr
r�s    r�getAvailableFontszPDFDocument.getAvailableFontszs[����)�)�.�.�0�1�	�/��+�+�	'�D��9�$�� � ��&�	'�	�����rc	�.�|jj|�|j}|j}|j	|�|j	|�d}|jj�}|r|j	|�}d}g}|j
}|j}|j}	|j}
t|j�x|_}	|dz
}||vrn�||}|	|}
t||
�}|j|�}tjsKtj r;	|
j"j$}|j)dt'|��d|dd�d��|j)|�}||
|<|j+|���|`t-|�}|dz
|k7rt/d|�d|����t1�}|j3d|�|j|�}|j)|�}t5||dz|j	|�|j	|�||j7��	�}|j|�}|j)|�t9|d
g�D]}|j;|��|j|�S#t'|
�}Y��VxYw)Nrr&z% z: class �2z 
zcounter z' doesn't match number to id dictionary )�	startxref�Size�Root�Info�Encryptr��	_digiSigs)rWrJrkrRr4rirfrgrh�PDFFilera�	__accum__�PDFIndirectObjectr5rr6r7r�rre�addr�lenr��PDFCrossReferenceTable�
addsection�
PDFTrailerr�r��sign)rErrR�
encryptref�encryptinfo�counter�ids�
numbertoid�idToNV�idToOb�idToOf�File�oid�obj�IO�IOf�	classname�offset�lno�xref�xreff�
xrefoffset�trailer�trailerf�dss                         rr5zPDFDocument.format�sQ��	
�����T�"��l�l���y�y�����s�����t���
��l�l�'�'�)�������4�J������_�_�
��0�0����������!(��(8�(8� 9�9������q�L�G��j�(�%��W�%�C���+�C�"�3��,�B��)�)�D�/�C��&�&�9�+@�+@�+� #�
�
� 6� 6�I�����s��Y�s��^�L�M��X�X�c�]�F� �F�3�K��J�J�s�O�%�&
�N��*�o���1�9�c�>��U\�^a�b�c�c�%�'������3�����D�!���X�X�e�_�
��"��q�5��>�>�#�&��>�>�$�'� �����
���>�>�$�'��������$�{�2�.�	�B��G�G�D�M�	��{�{�4� � ��=+� %�c�
�I�s�(J�
Jc�4�t|�}||jvS)z test for existence of named form)rArgr�s   r�hasFormzPDFDocument.hasForm�s��"�4�(���t���.�.rc�p�t|�}||jvr�|j|}t|d�r|j|St	|t
�r|j
�St	|t�r,t|jj|j�Stdt|�z��y)z�get the declared bounding box of the form as a list.
        If you specify a different PDF box definition (e.g. the
        ArtBox) and it has one, that's what you'll get.�_extra_pageCatcher_infoz'I don't understand the form instance %sN)rArgr3r<r,�PDFFormXObject�BBoxList�	PDFStreamr�
dictionary�dict�sequencer�r�)rEr��boxTyper��theforms     r�getFormBBoxzPDFDocument.getFormBBox�s���#�4�(���4�?�?�*��o�o�l�3�G��w�8�9��6�6�w�?�?��'�>�2��'�'�)�)��G�Y�/��G�.�.�3�3�G�<�E�E�F�F� �!J�T�RV�Z�!W�X�X�+rc��t|�S)ziLets canvas find out what form is called internally.
        Never mind whether it is defined yet or not.)rA�rEr�s  r�getXObjectNamezPDFDocument.getXObjectName�s���4� � rc�`�i}|D]}t|�}t|�}|||<�t|�S)z�construct an xobject dict (for inclusion in a resource dict, usually)
           from a list of form names (images not yet supported))rAr�rw)rE�	formnames�Dr�r��	references      r�xobjDictzPDFDocument.xobjDict�sB��
���	(�D�&�t�,�L�*�<�8�I�'�A�l�O�	(�
�Q��rc�z�t|t�}|j}|�|r|jtur|St|t�ri|j}|�(||k7r#tdt|��dt|�����||vr$tdt|��dt|��d���t	|�S|jdzx}|_|�dt|�z}||vr,||}||k7rtdt|�z��t	|�S|r||_|d	f|j|<||j|<|||<t	|�S)
Nzattempt to reregister object z with new name zobject of type z
 named as z, but not registeredr&�Rzredefining named object: r)r,r2rgr�r�r3r!r�r�r8rer\rfri)rEr-r��iobrg�intnamer\�others        rr4zPDFDocument.Reference�sK����Y�'���_�_�
��<���
�
�9K�(K��J��3�(�)��*�*�G���D�'�M� ���M�4��:�"/�0�0��j�(� �X\�]`�Xa�bg�ho�bp�!q�r�r�%�g�.�.�-1�-?�-?��-A�A�
��*��<��t�M�*�*�D��:���t�$�E��c�z� �!<�T�$�Z�!G�H�H�%�d�+�+��#'�C� �1>��0B��'�'��-�)-����
�&��
�4��!�$�'�'r)�MediaBoxrH)+rrr�defaultStreamFiltersrCrWr�pageCompressionr6�PDF_VERSION_DEFAULTr�r`r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrrrr5r:rErHrMr4rrrrYrYos������n�G��&�6�6�$�.�.��/��
3�j!�M�
.�
�N�@� ��
H�-�7���'�>�0���*$�&�(�(�*�*�1��C!�J/�
Y�$!�
	 �(rrY�true�false�nullc� �eZdZdd�Zd�Zd�Zy)r�c� �||_||_yrH)rFr�)rErFr�s   rr�zPDFText.__init__s�������rc���|j}t|�r|j|j�}t	j
|jj|��}d|zdzS)N�<�>)rFr
r.r��binascii�hexlifyrW)rEr<rF�results    rr5zPDFText.formatsT���F�F���Q�<�������"�A��!�!�(�"2�"2�"9�"9�!�"<�=���f�}�t�#�#rc�8�t�}|j|�SrH)rUr5)rE�dummydocs  r�__str__zPDFText.__str__ s���:���{�{�8�$�$rN)zutf-8)rrrr�r5rdrrrr�r�s���$�%rr�c��|SrHr)�ns r�	PDFnumberrg$s���Hrz[^()]c��tjd|�}d}|D]}|dk(r|dz
}�|dz}|dks�y|xrdxsdS)z+test whether a string is balanced in parensrr�(r&)�_re_cleanparens�sub)�srf�cs   r�_isbalancedrn*s\�����B�q�!�A�	�A�
����c�6�1�a�4�1�
��F�A���s�1�	�
�5�;�Q��!�rc�T�	|jd�y#t$r
}Yd}~yd}~wwxYw)z(return true if no Pdfdoc encoding errors�pdfdocr&Nr)r.�UnicodeEncodeError)�utext�es  r�_checkPdfdocrt5s)���
���X���������s��	'�'c�$�eZdZdZdd�Zd�Zd�Zy)roFc��t|t�r4|j|_|j|_|j|_y||_||_||_y)azs can be unicode/utf8 or a PDFString
        if escape is true then the output will be passed through escape
        if enc is raw then bytes will be left alone
        if enc is auto we'll try and automatically adapt to utf_16_be/utf_16_le if the
        effective string is not entirely in pdfdoc
        if self.unicodeEncValid unicode will use the specifed encoding
        N)r,rorl�escaper�)rErlrwr�s    rr�zPDFString.__init__?sD���a�	�"��S�S�D�F��(�(�D�K��u�u�D�H��D�F� �D�K��D�Hrc	�D�|j}t|dd�}t|�r�|dk(�rf	|jtj
�r|j
d�}nB|jtj�r|j
d�}n|j
d�}t|�r|jd�}n"tj
|jd�z}n�t|�r�|dk(r@t|�r|jd�}n�tj
|jd�z}nb|jr|j|j�}n:tj
|jd�z}nt!dt#|�z��t|d	d
�}t%|j&t(�s|j&j|�}d
}|rc	dt+|�z}|dzr|j-dd�}|dzr-t/|�r"|j-dd�j-dd�}t1|�Sd|zdzS#	|j
d�n'#tjdt|�����xYwY��xYw#t!d|�d
t|�����xYw)Nr��auto�	utf_16_be�	utf_16_le�utf8rpz	Error in z-PDFString argument must be str/unicode not %srwr&�(%s)zcannot escape � �z\012�
r(z\(riz\)�)�(�))rlr�r	�
startswith�codecs�BOM_UTF16_BE�decode�BOM_UTF16_LErtr.rr�r�r
�unicodeEncValidr�r�r8r,rWrCr�replacernr0)rEr<rlr��urw�ess       rr5zPDFString.formatOs2���F�F���d�5��(���1�:��f�}���|�|�F�$7�$7�8��H�H�[�1�����f�&9�&9�:��H�H�[�1���H�H�V�,��#�A���H�H�X�.��"�/�/�����0E�E����q�\��f�}���?�����*�A��+�+�A�H�H�[�,A�A�A��%�%��H�H�T�X�X�&���'�'�����(=�=���L�t�TU�w�V�W�W���h�q�)���(�*�*�<�8�� � �'�'��*�A��F��
G��i��l�*���a�x��Z�Z���-���a�x�K��O��Z�Z��c�*�2�2�5��=���R�=� ��!�8�d�?�"��E������*������d�1�g�%?�@���+��0
G� �!�T�!�W�!E�F�F�s0�B2I�J�J�I�J�$I;�;J�Jc�2�dt|j�zS)Nr})rrlrQs rrdzPDFString.__str__�s���	�$�&�&�)�)�)rN)r&ry)rrrr�r�r5rdrrrroro=s���O�� 2#�h*rro�!�~c��t|�}t|�D]1\}}||ks
||kDs|dvs�dtt|��ddz||<�3ddj	|�zS)Nz
%()<>{}[]#�#r�/r)r�	enumerate�hex�ord�join)r��lo�hi�L�irms      rr�r��si��	
�T�
�A���|�'���!��R�4�1�R�4�1��,��s�3�q�6�{�1�2��&�A�a�D�'������
��rc�D�eZdZdZdd�Zd�Zd�Zd�Zd�Zdd�Z	d	�Z
d
�Zy)
rwTNc�B�|�i|_y|j�|_y)zPdict should be namestring to value eg "a": 122 NOT pdfname to value NOT "/a":122N)rA�copy)rErAs  rr�zPDFDictionary.__init__�s���<��D�I��	�	��D�Irc�"�||j|<yrH�rA)rEr�r�s   r�__setitem__zPDFDictionary.__setitem__�s����	�	�$�rc� �|j|SrHr��rE�as  r�__getitem__zPDFDictionary.__getitem__�s���y�y��|�rc��||jvSrHr�r�s  r�__contains__zPDFDictionary.__contains__�s���D�I�I�~�rc�Z�|j|j|�|j|<yrH)r4rA)rEr�r<s   rr4zPDFDictionary.Reference�s"��"�,�,�T�Y�Y�t�_�=��	�	�$�rc�T�|j}	t|j��}t|t�s|j�|D�cgc]*}tt|�|�dzt|||�z��,}}|jrtjs|jdk(r|j|�}nJ|j}tt!dt#|�d��D]}||d��
dj|�}d|zdzS#tt	|���xYwcc}w)N� �forced��
 s<<
s
>>)rArr�r�rer,rrr5r��	multiliner�pdfMultiLiner��insert�reversed�ranger)	rEr<�INDrAr�r�r�rFr�s	         rr5zPDFDictionary.format�s����y�y��	���	�	��$�D��$�{�+�T�Y�Y�[�RV�W�Q�f�W�Q�Z��)�$�.�v�d�1�g�h�/G�G�W��W��N�N�y�5�5�$�.�.�(�:R������A��h�h�A��e�A�s�1�v�q�1�2�
���!�F��
��	�	�!��A��q�y�� � ��	��%��+����Ws�D�/D%�D"c�,�t|j�SrH)rwrArQs rr�zPDFDictionary.copy�s���T�Y�Y�'�'rc��|j}|j�D�cgc]}|jd�s�|��}}|D]}|j|�||dd<�ycc}w)Nr�r&)rAr�r��pop)rErKr��Ks    r�	normalizezPDFDictionary.normalize�sZ���I�I������6�1�A�L�L��$5�Q�6��6��	 �A��u�u�Q�x�A�a���e�H�	 ��
7s
�A�ArH�r�)rrrr�r�r�r�r�r4r5r�r�rrrrwrw�s/���I�$� ���>�!�&(� rrwc��eZdZd�Zd�Zy)�
checkPDFNamesc�@�ttt|��|_yrH)r�mapr��names)rEr�s  rr�zcheckPDFNames.__init__�s���#�g�e�,�-��
rc�\�|jd�st|�}||jvr|Sy)Nr�)r�r�r�)rEr�s  rr�zcheckPDFNames.__call__�s/������$��%�.�E��D�J�J���L�rN)rrrr�r�rrrr�r��s��.�rr�c��|dvr|Sy)N)rWrXr)r�s r�checkPDFBooleanr��s��� � ��,� rc��eZdZiZdd�Zd�Zy)�CheckedPDFDictionaryNc�D�tj||�|r||_yyrH)rwr��validate)rErAr�s   rr�zCheckedPDFDictionary.__init__�s�����t�D�)��X�T�]�8rc��||jvrtd|z��|j||�}|�td|�d|����tj|||�y)Nzinvalid key, %rz
Bad value z	 for key )r�r�rwr�)rEr�r��cvalues    rr�z CheckedPDFDictionary.__setitem__�s[���t�}�}�$��.��5�6�6�$����t�$�U�+���>��%��E�F�F��!�!�$�t�F�3r�NN)rrrr�r�r�rrrr�r��s���H�.�4rr�c�H�eZdZeeeeeeeedj
��edj
��edj
��edj
��edj
��edj
��edj
��edj
����Zy)�ViewerPreferencesPDFDictionaryz#UseNone UseOutlines UseThumbs UseOCzL2R R2Lz(MediaBox CropBox BleedBox TrimBox ArtBoxzNone AppDefaultz.Simplex DuplexFlipShortEdge DuplexFlipLongEdge)�HideToolbar�HideMenubar�HideWindowUI�	FitWindow�CenterWindow�DisplayDocTitle�NonFullScreenPageMode�	Direction�ViewArea�ViewClip�	PrintArea�	PrintClip�PrintScaling�DuplexN)rrrrAr�r��splitr�rrrr�r��s���
�+�+�,�)�,� /�&3�5Z�5`�5`�5b�&c�'����):�;�&�(R�(X�(X�(Z�[�&�(R�(X�(X�(Z�[�'�)S�)Y�)Y�)[�\�'�)S�)Y�)Y�)[�\�*�,=�,C�,C�,E�F�$�&V�&\�&\�&^�_��Hrr�c��eZdZdZd�Zd�Zy)�PDFStreamFilterZCompress�FlateDecodec�d�t|�r|jd�}tj|�S)Nr|)r
r.�zlib�compress�rE�texts  rr.zPDFStreamFilterZCompress.encode�s&���T�?��;�;�v�&�D��}�}�T�"�"rc�,�tj|�SrH)r��
decompress)rE�encodeds  rr�zPDFStreamFilterZCompress.decode�s�����w�'�'rN�rrr�pdfnamer.r�rrrr�r��s���G�#�(rr�c��eZdZdZd�Zd�Zy)�PDFStreamFilterBase85Encode�
ASCII85Decodec�X�ddlm}t|�}tjr||�}|S)Nr)�_wrap)�reportlab.pdfbase.pdfutilsr�rr�wrapA85)rEr�r�s   rr.z"PDFStreamFilterBase85Encode.encode�s&��4� ��&�������;�D��rc��t|�SrH)rr�s  rr�z"PDFStreamFilterBase85Encode.decode�s
�� ��&�&rNr�rrrr�r��s���G��'rr�c�"�eZdZdZdZdd�Zd�Zy)r?z@set dictionary elements explicitly stream.dictionary[name]=valuer&Nc�F�|�
t�}||_||_||_yrH)rwr@�content�filters)rEr@r�r�s    rr�zPDFStream.__init__	s$����&��J�$��������rc�b�|j}t|jj��}|j}|j
}|j�t
d��|�|j}|�vd|jvrht|�}|j�g}|D]8}|j|�}|jdt|j���:t|�|d<|jj|�}t!||�}t#|�|d<t!||�}	|	dz|zdzS)Nzstream content not set�Filterr�Lengths
stream
s
endstream
)r@rwrAr�r�r�r�rTr�reverser.r�r�r��PDFArrayrWr5r)
rEr<r@r�r��rf�fnamesr>�fc�fds
          rr5zPDFStream.formats���_�_�
�"�:�?�?�#7�#7�#9�:�
��,�,���,�,���<�<���5�6�6��?��3�3�G���8�:�?�?�#B��g��B��J�J�L��F��
5���(�(�7�+���
�
�a�����!3�4�	
5�$,�F�#3�J�x� ��"�"�)�)�'�2��
�G�X�
&��"�7�|�
�8��
�J��
)���-���"�>�1�1r�NNN)rrrrVr"r�r5rrrr?r?s��J��K��2rr?c��|�t}|j�dz}t|tjxrt
tgxstg��}d|_|S)Nr�)r�r�ztest stream)�teststreamcontent�stripr?r�useA85�PDFBase85Encode�PDFZCompressr#)r��Ss  r�
teststreamr/sS����#���m�m�o��$�G��G�%�,�,�O�/�,�1O�a�T`�Sa�	c�A�"�A�M��Hrz\
1 0 0 1 0 0 cm BT /F9 12 Tf 14.4 TL ET
1.00 0.00 1.00 rg
n 72.00 72.00 432.00 648.00 re B*
c�$�eZdZdZd�Zd�Zdd�Zy)r�Tc�$�t|�|_yrH)rrB)rErBs  rr�zPDFArray.__init__As
���X���
rc�`�tt|j|j��|_y)z'make all objects in sequence referencesN)rr�r4rBrIs  r�
ReferenceszPDFArray.ReferencesCs���S��!3�!3�T�]�]�C�D��
rc��|jD�cgc]}t||���}}|jrtjs|jdk(r|j|�}nct
|�}|dkDrB|j}ttd|d��D]}||d��
dj|�}ndj|�}d|zdzScc}w)Nr��
r�r�s[ s ])
rBr5r�rr�r�rr�r�r�)rEr<r�rsr�rfrFr�s        rr5zPDFArray.formatFs���*.�-�-�8�Q�V�A�x�
 �8��8��N�N�y�5�5�$�.�.�(�:R������A��!�f�A���t��(�(��!�%��A�r�"2�3� �A��a��K� ��I�I�a�L���I�I�a�L���q�y�5� � ��
9s�CNr�)rrrr�r�rr5rrrr�r�?s���I�'�E�!rr�c��eZdZdZy)�PDFArrayCompactFN)rrrr�rrrrrVs���Irrc��eZdZdZd�Zd�Zy)rr&c� �||_||_yrH)r�r�)rEr�r�s   rr�zPDFIndirectObject.__init__[s����	���rc�
�|j}|j|\}}|jj||�t	|j
|d��}t
|�d|�d��|z|jd�rdzdzSdzdzS)Nr&�r=r~z obj
�
rsendobj
)r�rfrWrOr5r�r0�endswith)rEr<r�rf�v�fcontents      rr5zPDFIndirectObject.format^s����y�y���2�2�4�8���1����!�!�!�Q�'��$�,�,��1�=����1�-�.�
��'�0�0��7��D�
��	�=B�D�
��	rN)rrrr"r�r5rrrrrYs���K��rrc��eZdZd�Zd�Zy)r�c��||_yrH)r�rGs  rr�zPDFObjectReference.__init__i�	����	rc��	td|j|jz�S#tdt	|j�z��xYw)Nz%s %s Rz:forward reference to %s not resolved upon final formatting)r0rfr�r�r�rIs  rr5zPDFObjectReference.formatksM��	k��Y��)L�)L�T�Y�Y�)W�W�X�X��	k��W�Z^�_c�_h�_h�Zi�i�j�j�s	�$'�#A
N�rrrr�r5rrrr�r�hs
���krr�c�(�eZdZefd�Zd�Zd�Zd�Zy)rc��g|_|jj|_d|_|j	td|z�dz�y)Nrz%%PDF-%s.%ssA
%���� ReportLab Generated PDF document http://www.reportlab.com
)�stringsrr�r1rr0)rEr|s  rr�zPDFFile.__init__ssD������\�\�(�(��
����	
���)�M�J�6�7�^�_�	rc��yrHrrQs r�closeOrResetzPDFFile.closeOrReset�s��rc�|�t|�}|j}|t|�z|_|j|�|S)zGshould be constructed as late as possible, return position where placed)r0r1rr�)rErlras   rrzPDFFile.add�s3���a�L�������S��V�m����
�
�1�
��
rc�8�dj|j�S)Nr)r�rrIs  rr5zPDFFile.format�s���x�x����%�%rN)rrrrVr�rrr5rrrrrqs��!4��
��&rrc��eZdZd�Zd�Zy)�PDFCrossReferenceSubsectionc� �||_||_yrH)�firstentrynumber�
idsequence)rEr#r$s   rr�z$PDFCrossReferenceSubsection.__init__�s�� 0���$��rc�R�|j}|j}t|�}t|�}i}|dk(rd|d<|dz}|j	dd�|j
}|j}||zdz
}	|D]n}
||
\}}||vr)td|�dt|
��dt||
�����||	kDs||krtd|�d|�d	|	����||z
}
|
||<||
}d
||fz||<�p|�d|��}|j	d|�|jd�tdj|��S)
z`id sequence should represent contiguous object nums else error. free numbers not supported (yet)rzstandard free entryr&z0000000000 65535 f zobject number collision r~zobject number z not in range z..z%0.10d %0.5d n rr�)r#r$rrr�rfrhr�r�rr0r�)rEr<r#r$�entries�nentries�takenr(rh�lastentrynumberr��numrN�rnumr1�	firstlines                rr5z"PDFCrossReferenceSubsection.format�sT���0�0���_�_�
��z�"���z�?�����Q��,�E�!�H���z�H��N�N�1�3�4��4�4���(�(�
�*�8�3�A�5���
	A�B�#�B�Z�N�S�'��e�|� �s�D�QS�H�VZ�[`�ac�[d�Ve�!f�g�g��?�"�c�*:�&:� �3�P`�bq�!r�s�s��'�'�D��E�#�J���^�F�,���/@�@�G�C�L�
	A� 0��:�	����q�)�$����r������7�+�,�,rNrrrrr!r!�s��%�-rr!c��eZdZd�Zd�Zd�Zy)rc��g|_yrH)�sectionsrQs rr�zPDFCrossReferenceTable.__init__�s	����
rc�R�t||�}|jj|�yrH)r!r/r)rE�
firstentryr&�sections    rr z!PDFCrossReferenceTable.addsection�s ��-�j�#�>���
�
���W�%rc���|j}|std��dg}|jD]}t||�}|j|��!t	dj|��S)Nzno crossref sectionssxref
r)r/r�r5rr0r�)rEr<r/r�rl�fss      rr5zPDFCrossReferenceTable.format�s`���=�=����3�4�4�
�K�����	�A���8�$�B�
�H�H�R�L�	�����!��%�%rN)rrrr�r r5rrrrr�s���&�&rrc��eZdZdd�Zd�Zy)r!Nc��||_|�|�td��t�x}|_d|fd|fd|fd|fd|fd|ffD]
\}	}
|
��	|
||	<�d|_y)	NzSize and Root keys requiredr�Prevrrr�rr�)rr�rwrAr�)rErrr7rrr�rrArfrs           rr�zPDFTrailer.__init__�s���"����<�4�<��:�;�;�(�?�*��t�y��t�n�v�t�n�v�t�n��t�n�t�R�j�9�g�2F�H�	�E�Q�q��}���Q��	� ��rc
��|jj|d��}djd|dtt	|j
��dg�S)Nr�r�rstrailer
s
startxref
s
%%EOF
)rAr5r�r0r-r)rEr<�fdicts   rr5zPDFTrailer.format�sN���	�	� � ��e� �4���x�x��� ��#�d�n�n�-�.����	r)NNNNNNrrrrr!r!�s��	 �	rr!c��eZdZdZdZed�ed�dd�Zdj�ZeZ	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zy)rjz
Document Rootr&rk�UseNoneN)�Type�PageModerpz�
        Dests Outlines Pages Threads AcroForm Names OpenAction PageMode URI
        ViewerPreferences PageLabels PageLayout JavaScript StructTreeRoot SpiderInfo
        MarkInfo Metadata Tabsc�r�|j|�|j}|j}i}|j�D]\}}t	|||�}|��|||<�|j
D]}t	||d�}|��|||<�|D]}||vs�|j
||�||<� t|�}t||�SrH)	�check_format�__Defaults__�__Refs__�itemsr��
__NoDefault__r4rwr5)rEr<�defaults�RefsrKr�rrAs        rr5zPDFCatalog.format�s������(�#��$�$���}�}�����>�>�#�	�C�A�a���Q�q�!�A��}���!��	��#�#�	�A���Q�t�$�A��}���!��	�
�	0�A��A�v��)�)�!�A�$�/��!��	0��Q����d�H�%�%rc�&�|jd�y)N�UseOutlines��setPageModerQs r�showOutlinezPDFCatalog.showOutlines������'rc�&�|jd�y)N�
FullScreenrIrQs r�showFullScreenzPDFCatalog.showFullScreens������&rc�*�|rt|�|_yyrH)r��
PageLayout)rE�layouts  r�
setPageLayoutzPDFCatalog.setPageLayouts���%�f�o�D�O�rc�*�|rt|�|_yyrH)r�r>)rE�modes  rrJzPDFCatalog.setPageModes���#�D�M�D�M�rc��y)zfor use in subclassesNrrIs  rr@zPDFCatalog.check_formatrKr)rrrr#r"r�rAr�rDrBr5rKrNrRrJr@rrrrjrj�s^��!�K��K�#�I�.�#�I�.���L�"�#(�%�'���H�&�*(�'�.�*�
rrjc�j�eZdZdZdZdZded�iZdj�Z	dgZ
d�Zd	�Zd
�Z
d�Zy)
rmzHPAGES TREE WITH ONE INTERNAL NODE, FOR "BALANCING" CHANGE IMPLEMENTATIONz	page treer&r=r%zKids Count Parent�Parentc��g|_yrH�r�rQs rr�zPDFPages.__init__s	����
rc� �|j|SrHrY)rE�items  rr�zPDFPages.__getitem__s���z�z�$��rc�:�|jj|�yrH)r�r�rEr�s  rr�zPDFPages.addPage!s���
�
���$�rc��|j}t|�}|j|�||_t	|�|_yrH)r�r�r�Kidsr�Count)rEr<r��kidss    rr@zPDFPages.check_format#s2���
�
����������!���	���Z��
rN)rrrrVr#r"r�rAr�rDrBr�r�r�r@rrrrmrmsI��R��K��K��G�G�,��L�'�-�-�/�M��z�H�� � � rrmc��eZdZdZdZdZded�iZdj�Z	dj�Z
dZd	Zd
Z
dZdZd
ZiZiZd
Zd�Zd�Zd
�Zd�Zd�Zy
)�PDFPagezPage dictionaryrr&r=r�z�Parent
        MediaBox Resources Contents CropBox Rotate Thumb Annots B Dur Hid Trans AA
        PieceInfo LastModified SeparationInfo ArtBox TrimBox BleedBox ID PZ
        TranszContents Parent ID�SiJNc�@�|jD]}t||d��yrH)rD�setattrrGs  rr�zPDFPage.__init__Fs#���&�&�	&�D��D�$��%�	&rc��||_yrHr�r�s  rr`zPDFPage.setCompressionJs
�� ��rc�~�|jrtd��t|�rdj|�dz}||_y)Nz&overridden! must set stream explicitlyr�)�Override_default_compilationr�rr��stream)rE�codes  r�	setStreamzPDFPage.setStreamLs7���,�,��E�F�F���;��9�9�T�?�4�'�D���rc�$�t|�|_yrH)rw�Trans)rE�tranDicts  r�setPageTransitionzPDFPage.setPageTransitionSs��"�8�,��
rc�f�|jry|jxsOt|jdvxrdd|j|j
gxsdd|j
|jg�|_|jsd|_n4t|jt�st|j�|_|jsu|j}|st�|_	nWt�}|jr,tjxrt t"gxst"g|_||_d|_||_	|j*s�t-�}|j/�|j0r|j3�n|j5�|j6r|j6|_|j:r|j:|_|j=|j>�|jA|jB�||_|jDs#|jF}|jI|�|_"yy)N)�Zirzpage stream)%rirSr��Rotate�
pageheight�	pagewidth�Annotsr,r2�Contentsrjrr?rzrr�rrr�r�r#�	Resources�PDFResourceDictionary�
basicFonts�	hasImages�allProcs�
basicProcs�XObjects�XObject�	ExtGState�
setShading�_shadingUsed�
setColorSpace�_colorsUsedrWr%r4)rEr<rjr�	resourcesr�s      rr@zPDFPage.check_formatVs����,�,���
�
�_��$�+�+��2I�2r�q�QR�SW�Sb�Sb�cg�cq�cq�Nr�3^�wx�z{�~B�~L�~L�NR�N]�N]�w^�*_��
��{�{��D�K��d�k�k�)�4�&�t�{�{�3����}�}��[�[�F�� *���
��K���#�#� )� 0� 0� T�o�|�5T� f�Ye�Xf�A�I�"��	� -��
� !��
��~�~�-�/�I�� � �"��~�~��"�"�$��$�$�&��}�}�$(�M�M�	�!��~�~�&*�n�n�	�#�� � ��!2�!2�3��#�#�D�$4�$4�5�&�D�N��{�{��N�N�E�"�,�,�U�3�D�K�r)rrrr#rir"r�rAr�rDrBrurtrjr{rzr~r��
_shadingsUsedrnr�r`rlrpr@rrrrcrc,s���#�K�$%� ��K��G�F�O��L������(�-�-�/�H��I��J�
�F��I��K��H��K��M��E�&�!��-�*4rrcc��eZdZy)�DuplicatePageLabelPageNrrrrr�r��r rr�c�4�eZdZdZdZiZdgZgZd�Zd�Z	d�Z
y)�
PDFPageLabelsNr�Numsc��g|_yrH)�labelsrQs rr�zPDFPageLabels.__init__�s	����rc�>�|jj||f�y)a� Adds a new PDFPageLabel to this catalog.
        The 'page' argument, an integer, is the page number in the PDF document
        with which the 'label' should be associated. Page numbering in the PDF
        starts at zero! Thus, to change the label on the first page, '0' should be
        provided as an argument, and to change the 6th page, '5' should be provided
        as the argument.

        The 'label' argument should be a PDFPageLabel instance, which describes the
        format of the labels starting on page 'page' in the PDF and continuing
        until the next encounter of a PDFPageLabel.

        The order in which labels are added is not important.
        N)r�r)rEr��labels   r�addPageLabelzPDFPageLabels.addPageLabel�s��	
�����D�%�=�)rc��	|jj�g}|jD]'\}}|j|�|j|��)t|�|_
tj||�S#t$rxt|jD�cgc]}|d��	ncc}wc}�}t	dtt
|D�cgc]}|j|�dkDs�|��ncc}wc}��z�Y��wxYw)Nrz-

!!!!! Duplicate PageLabel seen for pages %rr&)
r�rr��sortedrr�set�countrr�r�rjr5)rEr<r/�tmpr�r�r�s       rr5zPDFPageLabels.format�s���	A��K�K�������;�;�	!�K�D�%��M�M�$���M�M�%� �	!��V�$��	�� � ��x�0�0��&�	A�����4�1�!�A�$�4��4�5�C��O�RV�WZ�gj�[}�bc�nq�nw�nw�xy�nz�{|�n|�\]�[}��[}�W~�R��
A�	A�s/�A:�:C;�B#
�"!C;�C"�C"�!C;�:C;)rrr�__comment__r"rArDrBr�r�r5rrrr�r��s,���K��K��L��H�M��H��*� 1rr�c�^�eZdZdZdZiZdj
�ZdZdZ	dZ
dZdZd	Z
dd
�Zd�Zy)
�PDFPageLabelNrzType S P Stz:ARABIC ROMAN_UPPER ROMAN_LOWER LETTERS_UPPER LETTERS_LOWERrKrO�r�Ar�c���|rF|j�|jvrt||j��}t|�|_|rt|�|_|rt|�|_yy)a+
        A PDFPageLabel changes the style of page numbering as displayed in a PDF
        viewer. PDF page labels have nothing to do with 'physical' page numbers
        printed on a canvas, but instead influence the 'logical' page numbers
        displayed by PDF viewers. However, when using roman numerals (i, ii,
        iii...) or page prefixes for appendecies (A.1, A.2...) on the physical
        pages PDF page labels are necessary to change the logical page numbers
        displayed by the PDF viewer to match up with the physical numbers. A
        PDFPageLabel changes the properties of numbering at the page on which it
        appears (see the class 'PDFPageLabels' for specifying where a PDFPageLabel
        is associated) and all subsequent pages, until a new PDFPageLabel is
        encountered.

        The arguments to this initialiser determine the properties of all
        subsequent page labels. 'style' determines the numberings style, arabic,
        roman, letters; 'start' specifies the starting number; and 'prefix' any
        prefix to be applied to the page numbers. All these arguments can be left
        out or set to None.

        * style:

            - None:                       No numbering, can be used to display the prefix only.
            - PDFPageLabel.ARABIC:        Use arabic numbers: 1, 2, 3, 4...
            - PDFPageLabel.ROMAN_UPPER:   Use upper case roman numerals: I, II, III...
            - PDFPageLabel.ROMAN_LOWER:   Use lower case roman numerals: i, ii, iii...
            - PDFPageLabel.LETTERS_UPPER: Use upper case letters: A, B, C, D...
            - PDFPageLabel.LETTERS_LOWER: Use lower case letters: a, b, c, d...

        * start:

            -   An integer specifying the starting number for this PDFPageLabel. This
                can be used when numbering style changes to reset the page number back
                to one, ie from roman to arabic, or from arabic to appendecies. Can be
                any positive integer or None. I'm not sure what the effect of
                specifying None is, probably that page numbering continues with the
                current sequence, I'd have to check the spec to clarify though.

        * prefix:

            -   A string which is prefixed to the page numbers. Can be used to display
                appendecies in the format: A.1, A.2, ..., B.1, B.2, ... where a
                PDFPageLabel is used to set the properties for the first page of each
                appendix to restart the page numbering at one and set the prefix to the
                appropriate letter for current appendix. The prefix can also be used to
                display text only, if the 'style' is set to None. This can be used to
                display strings such as 'Front', 'Back', or 'Cover' for the covers on
                books.

        N)	�upper�__convertible__r�r�rrg�Stro�P)rE�style�start�prefixs    rr�zPDFPageLabel.__init__�sV��d��{�{�}�� 4� 4�4�g�d�5�;�;�=�>Y�e��U�^�D�F��I�e�,�$�'��I�f�-�4�6�6rc�8�tjr
t��y)NF)r�errorOnDuplicatePageLabelPager�)rE�oths  r�__lt__zPDFPageLabel.__lt__�s���2�2�(�*�*�rr�)rrrr#r"rAr�rDr��ARABIC�ROMAN_UPPER�ROMAN_LOWER�
LETTERS_UPPER�
LETTERS_LOWERr�r�rrrr�r��sH���K��K��L�!�'�'�)�M�R�O�
�F��K��K��M��M�6.�prr�c�"�t�}t�|_|j}|j	|�|_t
gd��|_t�}|j�|j�||_|j|�y)N)rrrdiI)
rcrrwr%r4rWr�rSryr|rzrxr�)r<r�r�r�s    r�testpager��sm���	�A���A�J��N�N�E��!�!�%�(�A�H��*�+�A�J�%�'�I�
����
�����A�K�	�M�M�!�rz/
<<
  /Count
      0
  /Type
      /Outlines
>>c�>�eZdZdZejdd�ZdZd�Zy)rqz
TEST OUTLINE!r�r&c�,�t|j�SrH)r0r�rIs  rr5zPDFOutlines0.formats������#�#rN)	rrrr#�DUMMYOUTLINEr�r�r"r5rrrrqrq
s#��!�K�����d�+�D��K�$rrqc�6�eZdZdZdxZxZxZxZxZxZ	xZ
Zd�Zy)�OutlineEntryObjectzan entry in an outlineNc���i}t|j�|d<|j|d<|j|d<dD]}t	||�}|��|||<�t|�}|j
|�S)N�TitlerW�Dest)r7�Next�First�Lastr`)ror�rWr�r�rwr5)rEr<rKrfr�PDs      rr5zOutlineEntryObject.formatsw�����t�z�z�*��'�
��k�k��(���I�I��&�	�;�	�A���a� �A��}���!��	��1�
���y�y��"�"r)
rrrrVr�r�rWr7r�r�r�r`r5rrrr�r�s2���AE�E�E�E�D�E�6�E�D�E�4�E�%�E�$��
#rr�c�Z�eZdZdZdxZZdZdZd�Zdd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zdd
�Zy)rra�
    takes a recursive list of outline destinations like::

        out = PDFOutline1()
        out.setNames(canvas, # requires canvas for name resolution
        "chapter1dest",
        ("chapter2dest",
        ["chapter2section1dest",
        "chapter2section2dest",
        "chapter2conclusiondest"]
        ), # end of chapter2 description
        "chapter3dest",
        ("chapter4dest", ["c4s1", "c4s2"])
        )

    Higher layers may build this structure incrementally. KISS at base level.
    Nr���c�J�i|_i|_g|_g|_i|_yrH)�destinationnamestotitles�destinationstotitles�
levelstack�	buildtree�	closedictrQs rr�zPDFOutlines.__init__;s'��(*��%�$&��!���������rc��|�|dk7rtd��t|t�stdt|�z��|dkrtd��|�|}|j}|j
}|j}||kDr8||dzkDrtd|�d|�d	|�d
|�d�	��|dzx}}|jg�||krT|d}|d=|d}	|	d}
t|
t�r|
\}}td
t|
�z��|
}|}||f|	d<|dz
}||kr�T|�y|dj|�||j|<|rd|j|<||_y)z/destinationname of None means "close the tree" Nrzclose tree must have level of 0zlevel must be integer, got %sznegative levels not allowedr&zcan't jump from outline level z
 to level z&, need intermediates (destinationname=z, title=r�r�z cannot reset existing sections: )r�r,r:r8�currentlevelr�r�r�tupler�r�r�)
rE�destinationname�levelr��closedr��stack�tree�current�previous�lastinpreviousr��sectionlists
             r�addOutlineEntryzPDFOutlines.addOutlineEntryBs����"�u�a�x��>�?�?��%��$�J�7V�Y]�^c�Yd�7d�,e�&e���7�*�%B�C�C��=�/�%��(�(�������~�~������\�!�^�#� �FR�TY�[j�lq�"r�s�s�#/��>�1�E�L��L�L����L� ��B�i�G��b�	��R�y�H�%�b�\�N��.��/�&4�#��{� �!C�d�>�FZ�!Z�[�[�%��%�� $�k�2����'��>�L��L� ��"�F�
�b�	����)�9>��%�%�o�6��Q�4�>�>�/�2�!��rc��||_yrH)�mydestinations)rE�destinationtrees  r�setDestinationszPDFOutlines.setDestinationsgs
��-��rc��i}td�|d<|j|d<|j|d<|j|d<t	|�}|j|�S)Nrtr=r`r�r�)r�r��first�lastrwr5�rEr<rKr�s    rr5zPDFOutlines.formatjsU�����J�'��&�	��Z�Z��'�
��Z�Z��'�
��I�I��&�	�
�1�
���y�y��"�"rc�J�|j||�}|j|�yrH��translateNamesr��rEr��nametree�desttrees    r�setNameszPDFOutlines.setNamests"���&�&�v�x�8�����X�&rc�J�|j||�}|j|�y)z1Explicit list so I don't need to do in the callerNr�r�s    r�setNameListzPDFOutlines.setNameListxs"���&�&�v�x�8�����X�&rc���|j}|j}|j}t|�r_t	|�s|jd�}|j
|�}|}||vr||}n|||<|||<||vrd||<||j
|�iSt|�rGg}|D]#}	|j|j||	���%t|t�rt|�S|Stdt|�z��)z=recursively translate tree of names into tree of destinationsr|r&z5in outline, destination name must be string: got a %s)r�r�r�rr
r��_bookmarkReferencerrr�r,r�r�r8)
rEr��objectr�r�r��destinationr�r��os
          rr�zPDFOutlines.translateNames}s	��#'�#@�#@� �#�8�8���N�N�	���=��V�$�v�}�}�V�/D�f� �3�3�F�;�K��E��1�1�0��8��27�(��/�05� ��-���"�)*�	�+�&��F�5�5�f�=�>�>���=��A��
9������,�,�V�Q�7�8�
9��&��'��Q�x���H��O�PT�U[�P\�\�]�]rc��|j�a|jr8|jd�|jd}|j||�|_ndx|_|_d|_d|_yt
|j|j�|_|j||jd��\|_|_d|_y)zPprepare all data structures required for save operation (create related objects)Nrr�r&r)
r�r�r�r�r�r�r�r�r��maketree)rEr<r��	destnamess    rrJzPDFOutlines.prepare�s������&�����$�$�T�*� �O�O�A�.�	�&*�&9�&9�&�)�&L��#�)-�-��
�T�Y���
���
���4�.�.����?��
�"&�-�-��$�:M�:M�XY�-�"Z����T�Y���
rc���|rd}|j|j�}n1|xjdz
c_d|jz}|�td��t	|�std��t|�}|dz
}dx}x}	}
|j}|j}t|�D�]}
t�}||_
|�d|
��}|j||�}|�||_|
|_|	�|}	|}
|}|}
||
}t|t�r|}n_t|t�r8	|\}}t||�|_|j#|||�\|_|_ntdt)|�z��	t+|j-��\\}}|||_||_t|t�s��||vs��|j |_��|	|
fS#tdt|�z��xYw#td	t/|�z��xYw)
N�Outliner&z
Outline.%sz2non-top level outline elt parent must be specifiedz-destinationtree must be list or tuple, got %s�.z7destination tree elt tuple should have two elts, got %sz4destination tree elt should be dict or tuple, got %sz3bad outline leaf dictionary, should have one entry )r4rtr�r�rrr�r�r�r�rWr�r7r,rAr�r`r�r�r�r8rrCr
r�r�)rEr<r�rWr=�	levelname�nelts�	lastindex�lastelt�firstref�lastrefr�r��index�eltobj�eltname�eltref�elt�leafdict�subsectionsr�r�s                      rr�zPDFOutlines.maketree�s���!�I��'�'��(9�(9�:�F��J�J�!�O�J�$�t�z�z�1�I��~� �!U�V�V��_�%��L�M�M��O�$���!�G�	�'+�+��+�(�W�#'�#@�#@� ��N�N�	��5�\�$	-�E�'�)�F�"�F�M�!*�E�2�G��'�'���8�F��"�%���%�����!���G��G��G�!�%�(�C��#�d�#����C��&�k�.1�+�X�{� %�[�)�<���.2�m�m�H�k�SY�.Z�+���v�{� �!W�Z^�_b�Zc�!c�d�d�
e�"&�x�~�~�'7�"8���%��4�E�:�F�L��F�K��#�e�$���):� &���}���I$	-�J�'�"�"��k�$�%^�ad�eh�ai�%i�j�j��
e� �!V�W^�_b�Wc�!c�d�d�s�G�!G�G�G6)rNNr�)rrrrVr�r�r%r�r�r�r�r5r�r�r�rJr�rrrrrrr#sL���&"�!�N�U��G��L��#"�J.�#�'�'�
^�6�(5#rrrc���t|t�r*|\}}t|j��\\}}|r||vryt	|�r/g}|D]}|jt
||���t|�Sy)zButility for outline: recursively count leaves in a tuple/list treer&)r,r�rrCrrr��sum)r�r�r�r�r�r��countsrss        rr�r��su���$�u��"&���;��x�~�~�/�0���%�����*���T�{����	/�A��M�M�%��9�-�.�	/��6�{��r�)ReportLab PDF Library - www.reportlab.comc�D�eZdZdZeZdZdZdZdZ	dZ
dZd�Zd	�Z
d
�Zd�Zy)ruz�PDF documents can have basic information embedded, viewable from
    File | Document Info in Acrobat Reader.  If this is wrong, you get
    Postscript errors while printing, even though it does not print.r��untitled�	anonymous�unspecifiedrNc��d|_y)N�False)�trappedrQs rr�zPDFInfo.__init__�	����rc��|j|j|j|jfD]}|j	t|���yrH)r�r�r�rrcr
)rE�	md5objectr/s   rr�zPDFInfo.digests<���*�*�d�k�k�4�<�<����G�	)�A����W�Q�Z�(�	)rc���i}t|j�|d<t|j�|d<t|j|j
��x|d<|d<t|j�|d<t|j�|d<t|j�|d<t|j�|d	<t|j�|d
<t|�}|j|�S)Nr��Author)�tsr�ModDate�CreationDate�Producer�Creator�Subject�Keywords�Trapped)ror�r��PDFDaterdrr�r�r�rr�rrwr5r�s    rr5zPDFInfo.formats������t�z�z�*��'�
�����,��(��+2�h�6I�6I�X\�Xk�Xk�+l�l��)��q��(�!�$�-�-�0��*�
� ����.��)�� ����.��)��!�$�-�-�0��*�
��t�|�|�,��)��
�1�
���y�y��"�"rc��|j�}|jj�D]\}}t|||��|S)z'shallow copy - useful in pagecatchering)�	__klass__�__dict__rCrf)rEr�r�rs    rr�zPDFInfo.copys?����� ���M�M�'�'�)�	!�D�A�q��E�1�a� �	!��r)rrrrVr�r�r�r�r�r�rrr�r�r5r�rrrruru�sA��H�!�H�9�G��E�
�F��G��H��N��)�
#�rruc�N�eZdZdZded�fgZdZedzZdd�Zd�Z	d�Z
d	�Zy
)�
Annotationzsuperclass for all annotations.r=�Annot)r=�Rectrw�Subtype)�Border�C�T�M�F�H�BS�AA�AS�Popupr��APc�f�|d}t|�st|�|d<t|d|�|d<|S)�@transform dict args from python form to pdf string rep as neededrrw)rr�ro)rE�drwrs    r�cvtdictzAnnotation.cvtdict$s8����y���T�{� ���A�f�I�!�!�J�-��7��*�
��rc��d|vr	|d}|d=nd}i}|jD]
\}}|||<�|j|�|jD]}||vs�td|z��|j	||��}|j
}|j
�D]*}||vs�t|jj�d|����t|�S)Nrwr&�keyword argument %s missing)rwz  bad annotation dictionary name )
rErc�requiredr�r'�	permittedr�r�rrw)rE�kwrwr&r��valr+s       r�AnnotationDictzAnnotation.AnnotationDict+s����r�>���\�F��8���F����-�-�	�J�T�#��A�d�G�	�	������M�M�	G�D��1�}� �!>��!E�F�F�	G�
�L�L��&�L�)���N�N�	��F�F�H�	j�D��9�$� �4�>�>�Kb�Kb�cg�!h�i�i�	j��Q��rc��td��)NzEDictString undefined for virtual superclass Annotation, must overload�r�rQs r�DictzAnnotation.Dict>s���`�a�arc�D�|j�}|j|�SrH�r1r5�rEr<rKs   rr5zAnnotation.formatBs���I�I�K���x�x��!�!rN�r&)rrrrVr�rEr*r+r'r.r1r5rrrrrsB��)����)�+�,�H�6�H��O�O�I�� �&b�"rrc�6�eZdZejdzZd�Zd�Zy)�FreeTextAnnotation)�DAc�<�||_||_||_||_yrH)rrwr8�otherkw)rErrwr8r,s     rr�zFreeTextAnnotation.__init__Hs����	� ��
������rc���i}|j|j�|j|d<|j|d<|j|d<d|d<|j
di|��S)Nrrwr8z	/FreeTextrr)rcr:rrwr8r.�rEr&s  rr1zFreeTextAnnotation.DictMs]����	��������I�I��&�	��
�
��*�
��'�'��$��"��)��"�t�"�"�'�Q�'�'rN)rrrrr+r�r1rrrr7r7Fs���$�$�w�.�I��
(rr7c�>�eZdZejdzZdd�Zd�Zd�Zy)�LinkAnnotation)r�r��PAc�J�||_||_||_||_||_yrH)rrrw�Destinationr:)rErrwrArr,s      rr�zLinkAnnotation.__init__Zs&�������	� ��
�&�����rc��y)Nz�
          << /Type /Annot /Subtype /Link /Rect [71 717 190 734] /Border [16 16 1]
             /Dest [23 0 R /Fit] >>
             rrQs r�dummyDictStringzLinkAnnotation.dummyDictStringas��rc���i}|j|j�|j|d<|j|d<|j|d<d|d<|j
|d<|jdi|��S)Nrrrwz/Linkrr�r)rcr:rrrwrAr.r<s  rr1zLinkAnnotation.Dictgsl����	��������k�k��(���I�I��&�	��
�
��*�
���)���$�$��&�	�"�t�"�"�'�Q�'�'rN)z[0 0 1])rrrrr+r�rCr1rrrr>r>Vs&���$�$�(��I���(rr>c�J�eZdZdZej
dzZgd�fd�Zdd�Zd�Zy)	�HighlightAnnotationa
    HighlightAnnotation is an annotation that highlights the selected area.

    Rect is the mouseover area that will show the contents.

    QuadPoints is a list of points to highlight, you can have many groups of
    four QuadPoints to allow highlighting many lines.
    )�
QuadPoints)g��(\��?g{�G�z�?gffffff�?c�J�||_||_||_||_||_yrH)rrwr:rG�Color)rErrwrGrIr,s      rr�zHighlightAnnotation.__init__|s%����	� ��
����$�����
rc�b�|d}|d}|d}t|t�st|�j|d��|d<t|t�st|�j|d��|d<t|t�st|�j|d��|d<t	|d|�|d<|S)r%rrGrr�r9rw)r,r-r�r5ro)rEr&rwr�QuadrIs      rr'zHighlightAnnotation.cvtdict�s�����y�������#����$��$� ���-�-�a�T�-�:�A�f�I��$��$�&�t�n�3�3�A�4�3�@�A�l�O��%��%��e�_�+�+�A�4�+�8�A�c�F�!�!�J�-��8��*�
��rc���i}|j|j�|j|d<|j|d<d|d<|j|d<|j
|d<|jdi|��S)Nrrwz
/HighlightrrGrr)rcr:rrwrGrIr.r<s  rr1zHighlightAnnotation.Dict�sj����	��������I�I��&�	��
�
��*�
�#��)���/�/��,������#��"�t�"�"�'�Q�'�'rNr5)	rrrrVrr+r�r'r1rrrrFrFqs,����$�$�'7�7�I�9K���(rrFc�6�eZdZejdzZd�Zd�Zy)�TextAnnotation)�Open�Namec��tj|||f|jdd�xst|�|jdd�d�|��y)NrGrI)rrr)rGrI)rFr�r��rect_to_quad)rErrwr,s    rr�zTextAnnotation.__init__�sO���$�$�T���	��6�6�,�t�4�J��T�8J��f�f�W�W�-�		�
�	rc�:�tj|�}d|d<|S)Nz/Textr)rFr1r<s  rr1zTextAnnotation.Dict�s ���$�$�T�*����)���rN)rrrrFr+r�r1rrrrNrN�s!��#�-�-�1��I��rrNc	�F�|d|d|d|d|d|d|d|dgS)z9
    Utility method to convert a Rect to a QuadPoint
    rr&rr'r)rs rrRrR�s@��
��G�T�!�W�d�1�g�t�A�w���G�T�!�W�d�1�g�t�A�w�0�0rc��eZdZd�Zd�Zy)�PDFRectanglec�B�||||f\|_|_|_|_yrH)�llx�lly�ulx�ury)rErXrY�urxr[s     rr�zPDFRectangle.__init__�s!��14�c�3��1C�.���$�(�D�H�d�hrc��t|j|j|j|jg�}t||�SrH)r�rXrYrZr[r5)rEr<r�s   rr5zPDFRectangle.format�s2���d�h�h����$�(�(�D�H�H�=�>���a��"�"rNrrrrrVrV�s
��D�#rrVc� �eZdZdd�Zd�Zd�Zy)rNc�L�|�
t�}|j|�||_yrH)r�_initr)rErrs   rr�zPDFDate.__init__�s!��
�:���B��
�
�2��*��rc�j�|j|_|j|_|j|_yrH)�YMDhms�date�dhh�dmm)rErs  rr`z
PDFDate._init�s#���I�I��	��6�6����6�6��rc�h�|jxsd�}tt||j��|�S)Nc��d||||||fzS)Nz!D:%04d%02d%02d%02d%02d%02d+00'00'r)�yyyy�mm�dd�hh�mrls      r�<lambda>z PDFDate.format.<locals>.<lambda>�s��7���2�b��1�-�.�r)rr5rorc)rEr��dfmts   rr5zPDFDate.format�s7���!�!�/�.�	
��i��d�i�i� 0�1�3�7�7rr�)rrrr�r`r5rrrrr�s��+��
8rrc�^�eZdZdZdxZxZZd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�Zy)rAaM

    not a PDFObject!  This is a placeholder that can delegates
    to a pdf object only after it has been defined by the methods
    below.

    EG a Destination can refer to Appendix A before it has been
    defined, but only if Appendix A is explicitly noted as a destination
    and resolved before the document is generated...

    For example the following sequence causes resolution before doc generation.
        d = Destination()
        d.fit() # or other format defining method call
        d.setPage(p)
        (at present setPageRef is called on generation of the page).
    Nc�.�||_dx|_|_yrH)r��fmtr�rGs  rr�zDestination.__init__�s����	�#�#���4�9rc���|j}|�td|jz��|j}|�td|jz��||_|j	|�S)NzYformat not resolved, probably missing URL scheme or undefined destination target for '%s'zTPage not bound, probably missing URL scheme or undefined destination target for '%s')rqr�r�r�r5)rEr<r>�ps    rr5zDestination.format�s����H�H���9�J�(C�FJ�FO�FO�(O�P�P��I�I���9�J�'}�AE�AJ�AJ�(J�K�K�����x�x��!�!rc�*�td|||�|_yrH)�PDFDestinationXYZrq)rE�left�top�zooms    r�xyzzDestination.xyz�s��$�T�4��d�;��rc�$�td�|_yrH)�PDFDestinationFitrqrQs r�fitzDestination.fit�s��$�T�*��rc�$�td�|_yrH)�PDFDestinationFitBrqrQs r�fitbzDestination.fitb�s��%�d�+��rc�&�td|�|_yrH)�PDFDestinationFitHrq�rErws  r�fithzDestination.fith�s��%�d�3�/��rc�&�td|�|_yrH)�PDFDestinationFitVrq�rErvs  r�fitvzDestination.fitv�s��%�d�D�1��rc�&�td|�|_yrH)�PDFDestinationFitBHrqr�s  r�fitbhzDestination.fitbh�s��&�t�S�1��rc�&�td|�|_yrH)�PDFDestinationFitBVrqr�s  r�fitbvzDestination.fitbv�s��&�t�T�2��rc�,�td||||�|_yrH)�PDFDestinationFitRrq)rErv�bottom�rightrws     r�fitrzDestination.fitr�s��%�d�D�&�%��E��rc��||_yrH�r�r]s  r�setPagezDestination.setPage�rr)rrrrV�representationr5r�r�ryr|rr�r�r�r�r�r�rrrrArA�sP��� &*�)�N�)�V�d�$�"�<�+�,�0�2�2�3�F�rrAc��eZdZdZd�Zd�Zy)ru�XYZc�<�||_||_||_||_yrH)r�rwrxrv)rEr�rvrwrxs     rr�zPDFDestinationXYZ.__init__s����	������	���	rc���|j|j�}t|t|j�|j
|j|jg�}t||�SrH)	r4r�r�r��typenamervrwrxr5�rEr<�pagerefr�s    rr5zPDFDestinationXYZ.formatsM���$�$�T�Y�Y�/��������!7����D�H�H�d�i�i�Y�[���a��"�"rN�rrrr�r�r5rrrrurus���H��
#rruc��eZdZdZd�Zd�Zy)r{�Fitc��||_yrHr�r]s  rr�zPDFDestinationFit.__init__rrc��|j|j�}t|t|j�g�}t||�SrH)r4r�r�r�r�r5r�s    rr5zPDFDestinationFit.formats;���$�$�T�Y�Y�/��������!7�9�;���a��"�"rNr�rrrr{r{
s���H��#rr{c��eZdZdZy)r~�FitBN�rrrr�rrrr~r~s���Hrr~c��eZdZdZd�Zd�Zy)r��FitHc� �||_||_yrH)r�rw)rEr�rws   rr�zPDFDestinationFitH.__init__s����	�3�$�(rc��|j|j�}t|t|j�|j
g�}t
||�SrH)r4r�r�r�r�rwr5r�s    rr5zPDFDestinationFitH.formatsA���$�$�T�Y�Y�/��������!7����C�E���a��"�"rNr�rrrr�r�s���H�'�#rr�c��eZdZdZy)r��FitBHNr�rrrr�r�"����Hrr�c��eZdZdZd�Zd�Zy)r��FitVc� �||_||_yrH)r�rv)rEr�rvs   rr�zPDFDestinationFitV.__init__'s����	�D�$�)rc��|j|j�}t|t|j�|j
g�}t
||�SrH)r4r�r�r�r�rvr5r�s    rr5zPDFDestinationFitV.format)sA���$�$�T�Y�Y�/��������!7����D�F���a��"�"rNr�rrrr�r�%s���H�)�#rr�c��eZdZdZy)r��FitBVNr�rrrr�r�.r�rr�c��eZdZdZd�Zd�Zy)r��FitRc�J�||_||_||_||_||_yrH)r�rvr�r�rw)rEr�rvr�r�rws      rr�zPDFDestinationFitR.__init__3s$����	�D�$�)�f�$�+��d�j�Y\�PT�PXrc���|j|j�}t|t|j�|j
|j|j|jg�}t||�SrH)
r4r�r�r�r�rvr�r�rwr5r�s    rr5zPDFDestinationFitR.format5sY���$�$�T�Y�Y�/��������!7����D�K�K�QU�Q[�Q[�]a�]e�]e�f�h���a��"�"rNr�rrrr�r�1s���H�]�#rr�c��eZdZdZd�Zdj�D���cgc]
}t
|���c}}}ZdZd�Z	d�Z
d�Zd�Zd	�Z
d
�Zycc}}}w)ryz7each element *could* be reset to a reference if desiredc	��|jD]}t|||j|i���!|j�d|vr|jd�|_yy�N�ProcSet)�dict_attributesrfr�r}r�)rE�kwds�_s   rr�zPDFResourceDictionary.__init__@sV���%�%�	+�A��D��4�8�8�A�b�>�*�	+�	
��������(�(�9�-�D�L�rzPDF Text ImageB ImageC ImageI)�
ColorSpacerr��Font�Pattern�
Properties�Shadingc�&�|j|_yrH��stdprocsr�rQs rr|zPDFResourceDictionary.allProcsJs
���}�}��rc�,�|jdd|_y)Nrr�rQs rr}z PDFResourceDictionary.basicProcsNs���}�}�R�a�(��rc�,�tt�|_yrH)r�r$r�rQs rrzz PDFResourceDictionary.basicFontsQs��&�z�2��	rc�d�|j�D]\}}t|�|j|<�yrH)rCr�r�)rE�
colorsUsedrmrls    rr�z#PDFResourceDictionary.setColorSpaceTs1���#�#�%�	7�C�A�a�!3�A�!6�D�O�O�A��	7rc�d�|j�D]\}}t|�|j|<�yrH)rCr�r�)rE�shadingUsedrmrls    rr�z PDFResourceDictionary.setShadingXs0���$�$�&�	4�C�A�a�0��3�D�L�L��O�	4rc�"�i}|jD]7}t||�}t|t�r|s�"t	|�}|||<�3|||<�9|j
}d}t
|�r|rt|�}|||<n|||<t	|�}t||�Sr�)	r�r�r,rArwr�rr�r5)rEr<rK�dnamer�dvr�s       rr5zPDFResourceDictionary.format\s������)�)�	�E���e�$�A��!�D�!��&�q�)�B�!�A�e�H���%��	�
�L�L������8���a�[����%���A�e�H�
�1�
���b�(�#�#rN)rrrrVr�r�r�r�r�r|r}rzr�r�r5)�.0rlr�s000rryry>sV��A�.�%D�$I�$I�$K�L�L�q���
�L�H�h�O�%�)�3�7�4�$��+Ms�A
ryc�b�eZdZdZdZdj�ZdZdZdj�Z	d�Z
y)	�PDFType1Fontz"no init: set attributes explicitlyr&zType Subtype BaseFont Namer��Type1z;FirstChar LastChar Widths Encoding ToUnicode FontDescriptorc��i}|jD])}t||�s�t||�}t|�||<�+|jD] }t||�s�t||�}|||<�"t|�}|j
|�SrH)�name_attributesr3r�r��local_attributesrwr5)rEr<rKr�r�r�s      rr5zPDFType1Font.format�s������(�(�	)�D��t�T�"���d�+��!�%�.��$��	)��)�)�	 �D��t�T�"���d�+����$��	 �
�1�
���y�y��"�"rN)rrrrVr"r�r�r=rr�r5rrrr�r�ws6��,��K�2�8�8�:�O��D��G�T�Z�Z�\��#rr�c��eZdZdZy)�PDFTrueTypeFont�TrueTypeN)rrrrrrrr�r��s���Grr�c�H�eZdZdxZxZxZxZxZxZZ	dZ
dZd�Zd�Z
d�Zd�Zy)r=Nr&rc�<�||_||_||_||_yrH)�lowerx�lowery�upperx�uppery)rEr�r�r�r�s     rr�zPDFFormXObject.__init__�s�����&�d�k�f�$�+�RX�d�krc�\�t|�rdj|�}t|�|_y)Nr�)rr�r0rj)rEr�s  r�
setStreamListzPDFFormXObject.setStreamList�s!����;��9�9�T�?�D���o��rc��|jrt|jj�S|j|j|j
|jgS)z4get the declared bounding box for the form as a list)�BBoxrrBr�r�r�r�rQs rr>zPDFFormXObject.BBoxList�s=���9�9���	�	�*�*�+�+��K�K����d�k�k�4�;�;�G�Grc��|jxs7t|j|j|j|j
g�|_|jxs
tgd��|_|jsd|_ntd��|js=|j}|st�|_	nt�}||_
d|_||_	|jskt!�}|j#�|j$r|j'�n|j)�|j*r|j*|_||_|j.r6t0j2xrt4t6gxst6g|j_|jj:}t=d�|d<t=d�|d<d|d	<|j|d
<|j|d<|j|d<|jj?|�S)
N)r&rrr&rrz-annotations don't work in PDFFormXObjects yetzxobject form streamrr=�Formrr&�FormTyper��Matrixrx) r�r�r�r�r�r�r�rvr�rwrjrr?r�r#rxryrzr{r|r}r~rrzrr�rrr�r@r�r5)rEr<rjrr��sdicts      rr5zPDFFormXObject.format�s����I�I�_��4�;�;����T�[�[�RV�R]�R]�*^�!_��	��k�k�A�X�.@�%A����{�{��D�K��L�M�M��}�}��[�[�F�� *���
��K��"��	� 5��
� !��
��~�~�-�/�I�� � �"��~�~��"�"�$��$�$�&��}�}�$(�M�M�	�!�$�D�N����$-�$4�$4�$X�/�<�9X�$j�]i�\j�D�M�M�!��
�
�(�(���	�*��f�
�"�6�?��i����j���	�	��f�
��+�+��h��!�^�^��k���}�}�#�#�H�-�-r)rrrr~rvr�r�rwrjrxr{rzr�r�r>r5rrrr=r=�sI��IM�L�H�L�v�L��L�v�L��L�6�I��I��K�Y�&�
H�'.rr=c��eZdZdZdd�Zd�Zy)�PDFPostScriptXObjectz,For embedding PD (e.g. tray commands) in PDFNc��||_yrH�r�)rEr�s  rr�zPDFPostScriptXObject.__init__�rrc��t�}|j|_d|_|j}t	d�|d<t	d�|d<|j|�S)Nzxobject postscript streamrr=�PSr)r?r�r#r@r�r5)rEr<rr�s    rr5zPDFPostScriptXObject.format�sO���K���L�L��	�3��
������	�*��f�
�"�4�=��i���x�x��!�!rrH)rrrrVr�r5rrrr�r��s��2��"rr��	DeviceRGB�
DeviceGray�
DeviceCMYK)�RGBr��CMYKc�8�eZdZd	d�Zd�Zd�Zd�Zd�Zd�Zd�Z	y)
�PDFImageXObjectNc�4�||_d|_d|_d|_d|_t
jxrdxsd|_d|_||_	|�yt|d�r|j|�yd	dl}|jj|�dj�}t!|�}	|d
vr|j#|�s3t
jr|j%|�n|j'|�|j)�y#|j)�wxYw)N��r&r�)r�rz�
            003B00 002700 002480 0E4940 114920 14B220 3CB650
            75FE88 17FF8C 175F14 1C07E2 3803C4 703182 F8EDFC
            B2BBC2 BB6F84 31BFC2 18EA3C 0E3E00 07FC00 03F800
            1E1800 1FF800>
            �jpeg_fhr)z.jpgz.jpeg)r��width�height�bitsPerComponent�
colorSpacerr��_filters�
streamContent�maskr3�loadImageFromSRCr��path�splitext�lowerr�loadImageFromJPEG�loadImageFromA85�loadImageFromRawr�)rEr��sourcer�r��ext�srcs       rr�zPDFImageXObject.__init__	s�����	���
���� !���&���!�(�(�?�-?�E�2��
������	��>��
�V�I�
&��!�!�&�)�
��'�'�"�"�6�*�1�-�3�3�5�C���'�C�
��/�/�D�4J�4J�3�4O� �'�'��-�-�c�2��-�-�c�2��	�	����	�	��s
�,AD�Dc���g}tj||d��}|s|j|d�S|D�cgc]}|j���}}|dj	�}t|d�t|d�c|_|_dddd	�|d
|_d|_	d|_
|r|j|d�n|jd
k(rd|_dj|dd�|_ycc}w)NT��IMG�
detectJpegrr&r'r�r�r��z/RGBz/Gz/CMYK���r�r�ryrr�)r�makeA85Imagerr�r�r:r�r�r�r�r��_checkTransparencyr�r�r�)rErr�	imagedatarl�wordss      rrz PDFImageXObject.loadImageFromA85*s������)�)�&�S�D�I�	���(�(��Q��0�0�(1�2�1�Q�W�W�Y�2�	�2��!��"�"�$��#&�u�Q�x�=��U�1�X����
�D�K�"-�L�,�W�X]�^_�X`�a��� !���5��
���'�'��A��/�
�Y�Y��
�D��	��W�W�Y�q��_�5����3s�C.c���		tj|�}|jd�	|d|dc|_|_d|_|ddk(rd|_n|ddk(rd|_nd	|_d|_|j�|_	tjr)t|j�|_	d
|_
d|_yd|_
d|_y#|jd�wxYw#YyxYw)
NrFr&rrr�r'r�r�)r��	DCTDecode)rT)r�readJPEGInfo�seekr�r�r�r��_dotrans�readr�rr�rr�r�)rE�	imageFilerRs   rrz!PDFImageXObject.loadImageFromJPEG9s���	�
"��,�,�Y�7�����q�!�#'�q�'�4��7���
�D�K� !�����7�a�<�*�D�O�
�!�W��\�)�D�O�*�D�O��D�M�&�^�^�-������!2�4�3E�3E�!F�D��7�D�M���	��)�D�M���	���'���q�!��	��s�C�C'�C$�$C'�'C+c��g}tj||d��}|s|j|d�S|dj�}t	|d�|_t	|d�|_dddd	�|d
|_d|_d|_	|r|j|d�n|jd
k(rd|_dj|dd�|_
y)NTrrr&r'r�r�r�rrr�r�ryrr�)r�makeRawImagerr�r:r�r�r�r�r�rr�r�r�)rErrrrs     rrz PDFImageXObject.loadImageFromRawSs������)�)�&�S�D�I�	���(�(��Q��0�0��!��"�"�$����q��]��
��%��(�m���"-�L�,�W�X]�^_�X`�a��� !���&��
���'�'��A��/�
�Y�Y��
�D��	� �X�X�i��"�o�6��rc��|jdk(r�|jrYd|_tt|jj	��|jd��|_ddg|j
_y|j�}|r |d|d|d|d|d|df|_yd|_yt|jd�r:|jj�}|d|d|d|d|d|df|_yy)Nry)r�rr&r�rgb)
r��_dataAr�r�
getRGBData�_smask�_decode�getTransparentr3r!)rE�im�tcr�s    rrz"PDFImageXObject._checkTransparencybs����9�9�f���y�y� ��	�-�i��	�	�8L�8L�8N�.O�PR�PY�PY�_c�d���'(��e����#��&�&�(���!#�A���1��r�!�u�b��e�R��U�B�q�E� J�D�I� $�D�I�
�T�Y�Y�u�
%��	�	�
�
��A��!��Q�q�T�!�A�$�q��t�A�a�D��1��5�D�I�&rc��|j�}|r|j|�y|j�\|_|_|j�}t
j|�|_tjr"t|j�|_d|_nd|_t|j|_d|_|j#|�y)z%Extracts the stream, width and heightrrrN)r�r�getSizer�r�r#r�r�r�rr�rr��_mode2CSrTr�r�r)rEr'�fpr�s    rrz PDFImageXObject.loadImageFromSRCrs���
�Z�Z�\��
��"�"�2�&�&(�j�j�l�#�D�J����-�-�/�C�!%���s�!3�D�����%6�t�7I�7I�%J��"� =��
� .��
�%�b�g�g�.�D�O�$%�D�!��#�#�B�'rc���t|j��}|j}td�|d<td�|d<|j|d<|j
|d<|j|d<t|j�|d	<|jd
k(rt|dd�rtgd
��|d<n%t|dd�rt|j�|d<ttt|j��|d<t|j�|d<|jrt|j�|d<t|dd�r|j|d<|j!|�S)Nr�rr=�Imager�Width�Height�BitsPerComponentr�r�rr)r&rr&rr&rr&r�Decoder%r�r��Mask�smask�SMask)r?r�r@r�r�r�r�r�r�r�r%r�r�rr�r4r5)rEr<rrAs    rr5zPDFImageXObject.format�s%���� 2� 2�3���|�|���y�)��V��!�'�*��Y���
�
��W�
�����X��#'�#8�#8��
� �$�T�_�_�5��\���?�?�L�(�W�T�*�Q�-G�%�&7�8�D��N�
�T�)�D�
)�%�d�l�l�3�D��N�!�#�g�d�m�m�"<�=��X���T�/�/�0��X���9�9�X�d�i�i�%8�d�6�l��4���%�t�z�z�t�G�}��x�x��!�!rr�)
rrrr�rrrrrr5rrrr�r�s&���B
6��4
7�6� (�&"rr�c��eZdZd�Zd�Zd�Zy)r�c���ddlm}t||�s"td|jj
z��|js"td|jj
z��||_y)Nr)�	CMYKColorz%s needs a CMYKColor argumentz-%s needs a CMYKColor argument with a spotName)�reportlab.lib.colorsr8r,r�r�rr�r�)rEr�r8s   rr�zPDFSeparationCMYKColor.__init__�sS��2��$�y�)��<�t�~�~�?V�?V�V�W�W�����L�t�~�~�Of�Of�f�g�g���	rc��gj}t|jj��D]|\}}t|�}|dk(r0|dk(r|d�|d��,|t	|��|d��F|dk(r	|d�n!|d�|t	|��|d�|d��~d	d
j|j�zS)zpcreate the postscript code for the tint transfer function
        effectively this is tint*c, tint*y, ... tint*kr'�r�z0.0�mulr�dup�exchz{%s}r~)rr�r�r9r-r��__self__)rErOr�rs    r�_makeFuncPSz"PDFSeparationCMYKColor._makeFuncPS�s���
�I�I���T�Y�Y�^�^�-�.�	�C�A�a��A�h�A��!�t��c�6��e�H��e�H��c�!�f�I��e�H��a�4��e�H��e�H��c�!�f�I��e�H��&�	�!	�"����!�*�*�-�.�.rc��ttd�t|jj�td�t	tt
dtd�td����|j�d��f�S)N�
Separationr�r()rr&)rr&rr&rr&rr&)�FunctionType�Domain�Range)r@r�r�)rr�r�r�r?rwrAr@rQs rr�zPDFSeparationCMYKColor.value�sr����L�)��D�I�I�.�.�/��L�)��#0��)*�#2�5�#9�"1�2C�"D�2�$�
!%� 0� 0� 2� $��	
 �
�
	rN)rrrr�r@r�rrrr�r��s���/�.rr�c�4�eZdZdZgZdZedzZd�Zd�Zd�Z	y)�PDFFunctionz"superclass for all function types.)rCrD)rEc��i}|jD]
\}}|||<�|j|�|jD]}||vs�td|z��|j}|j�D]}||vs�td|z��t
|�S�Nr)z!bad annotation dictionary name %s)rErcr*r�r+r�rw)rEr,r&r�r-r+s      r�FunctionDictzPDFFunction.FunctionDict�s������-�-�	�J�T�#��A�d�G�	�	������M�M�	G�D��1�}� �!>��!E�F�F�	G��N�N�	��F�F�H�	M�D��9�$� �!D�t�!K�L�L�	M��Q��rc��td���Nz?Dict undefined for virtual superclass PDFShading, must overloadr0rIs  rr1zPDFFunction.Dict�����Z�[�[rc�F�|j|�}|j|�SrHr3r4s   rr5zPDFFunction.format�����I�I�h����x�x��!�!rN)
rrrrVrEr*r+rJr1r5rrrrGrG�s)��,��H�)�H���#�I� �\�
"rrGc��eZdZejded�fgzZejdzZejdzZd�Zd�Z	y)�PDFExponentialFunctionrD)r;g�?)�N)�C0�C1rRc�<�||_||_||_||_yrH)rSrTrRr:)rErSrTrRr,s     rr�zPDFExponentialFunction.__init__�s�������������rc���i}|j|j�d|d<t|j�|d<t|j�|d<|j
|d<|jdi|��S)NrrCrSrTrRr)rcr:rrSrTrRrJ�rEr<r&s   rr1zPDFExponentialFunction.Dict�sh����	���������.��!�$�'�'�*��$��!�$�'�'�*��$������#�� �t� � �%�1�%�%rN)
rrrrGrErr*r+r�r1rrrrQrQ�sJ���#�#��/�*�2M�'N�&O�O�H��#�#�f�,�H��%�%�(9�9�I��
&rrQc�T�eZdZejdzZej
dzZd�Zd�Zy)�PDFStitchingFunction)�	Functions�Bounds�Encodec�<�||_||_||_||_yrH)rZr[r\r:)rErZr[r\r,s     rr�zPDFStitchingFunction.__init__�s��"�����������rc�>�i}|j|j�d|d<t|jD�cgc]}|j	|���c}�|d<t|j
�|d<t|j�|d<|jdi|��Scc}w)Nr'rCrZr[r\r)rcr:r�rZr4r[r\rJ)rEr<r&r/s    rr1zPDFStitchingFunction.Dict�s�����	���������.��!�$�.�.�"Q�Q�8�#5�#5�a�#8�"Q�R��+���t�{�{�+��(���t�{�{�+��(�� �t� � �%�1�%�%��#Rs�BN)rrrrGr*r+r�r1rrrrYrY�s.���#�#�&G�G�H��%�%�(I�I�I��
&rrYc�0�eZdZdZdZedzZd�Zd�Zd�Zy)�
PDFShadingz!superclass for all shading types.)�ShadingTyper�)�
Backgroundr��	AntiAliasc���i}|j|�|jD]}||vs�td|z��|j}|j	�D]}||vs�td|z��t|�SrI)rcr*r�r+r�rw)rEr,r&r�r+s     r�ShadingDictzPDFShading.ShadingDict	s�����	������M�M�	G�D��1�}� �!>��!E�F�F�	G��N�N�	��F�F�H�	M�D��9�$� �!D�t�!K�L�L�	M��Q��rc��td��rLr0rIs  rr1zPDFShading.Dict	rMrc�F�|j|�}|j|�SrHr3r4s   rr5zPDFShading.format	rOrN)	rrrrVr*r+rer1r5rrrr`r`	s%��+�,�H��<�<�I�
 �\�
"rr`c�T�eZdZejdzZej
dzZd�Zd�Zy)�PDFFunctionShading)�Function)rDr�rjc�.�||_||_||_yrH)rjr�r:)rErjr�r,s    rr�zPDFFunctionShading.__init__#	s�� ��
�$�����rc���i}|j|j�d|d<t|j�|d<|j	|j
�|d<|jdi|��S)Nr&rar�rjr)rcr:r�r�r4rjrerWs   rr1zPDFFunctionShading.Dict'	sa����	���������-��!�$�/�/�2��,�� �*�*�4�=�=�9��*�
��t���$�!�$�$rN�rrrr`r*r+r�r1rrrriri 	s-���"�"�]�2�H��$�$�'G�G�I��%rric�T�eZdZejdzZej
dzZd�Zd�Zy)�PDFAxialShading��Coordsrj�rqrDrj�Extendc�D�||||f|_||_||_||_yrH�rqrjr�r:)rE�x0�y0�x1�y1rjr�r,s        rr�zPDFAxialShading.__init__3	s'���2�r�2�&��� ��
�$�����rc��i}|j|j�d|d<t|j�|d<t	|j
�|d<|j
|j�|d<|jdi|��S)Nrrar�rqrjr�	rcr:r�r�rrqr4rjrerWs   rr1zPDFAxialShading.Dict8	�s����	���������-��!�$�/�/�2��,��%�d�k�k�2��(�� �*�*�4�=�=�9��*�
��t���$�!�$�$rNrmrrrroro/	�2���"�"�%;�;�H��$�$�(6�6�I��
%rroc�T�eZdZejdzZej
dzZd�Zd�Zy)�PDFRadialShadingrprrc	�H�||||||f|_||_||_|	|_yrHru)
rErvrw�r0rxry�r1rjr�r,s
          rr�zPDFRadialShading.__init__E	s+���2�r�2�r�2�.��� ��
�$�����rc��i}|j|j�d|d<t|j�|d<t	|j
�|d<|j
|j�|d<|jdi|��S)Nr'rar�rqrjrr{rWs   rr1zPDFRadialShading.DictJ	r|rNrmrrrrrA	r}rr�__main__z-There is no script interpretation for pdfdoc.)rrH)��__version__rVr_r�r��collectionsrrr�	reportlabrr�rrrr	r
rrr
rr�reportlab.lib.rl_accelrrrrr�hashlibr�sysr�	Exceptionrr!r"r#r$r%rVrAr�r0r5rA�formNamerCr2rUrY�PDFtrue�PDFfalse�PDFnullr�rg�re�compilerjrnrtro�chrr�rwr�r�r�r�r�rr�rr?rr�r�rrr�rr!rr!rjrmrcr�r�r�r�r�rqr�rrr�r�rurr7r>rFrNrRrVrrArur{r~r�r�r�r�r�ryr�r�r=r�r+r�r�rGrQrYr`rirorrr�rrr�<module>r�sN��
��	����#�&��P�P�P�Z�Z�(���	�y�	�&�������
�	��������=�'�4'�����	�	��y��
`(�)�`(�F
����
��%�i�%�
�
���
�
�7�#���	��G*�	�G*�R��I��T���+ �I�+ �Z��/�4�=�4��%9��((�(�(�)��	'�	'�.�/��(2�	�(2�T	
���
!�y�!�.�h��
�	�
�k��k�&�i�&�<#-�)�#-�J&�Y�&� ���63
��3
�j �z� �0T4�j�T4�n	�Y�	�&1�J�&1�PH�:�H�V
���$�9�$�
#��
#�~#�)�~#�@
� @��'�i�'�T&"��&"�P(��(� (�Z�(�6((�*�((�T
�(�
�0�#�9�#�8�i�8�(-�)�-�`
#�	�
#�#�	�#��*��#��#��,��#��#��,��#��#�1$�I�1$�r#�9�#�4�l��F>.�Y�>.�@"�9�"���l�	C��S"�i�S"�j.�.�`"�)�"�8&�[�&�$&�;�&�""��"�2
%��
%�%�j�%�$%�z�%�$�Z��	�
9�:�r

Zerion Mini Shell 1.0