Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 `”b'`ã@sxdZdZddlZddlZddlZddlmZddlmZddl m Z ddl m Z m Z mZmZmZmZmZmZmZmZddlmZmZmZmZdd lmZdd lmZdd lmZGd d „d e ƒZ!dZ"dZ#dZ$dZ%dZ&d¸Z'e(d¹d�Z)dd„Z*dºdd„Z+dd„Z,e,Z-Gdd„dƒZ.Gdd „d ƒZ/Gd!d"„d"e/ƒZ0Gd#d$„d$e/ƒZ1d%Z2d&Z3d'Z4Gd(d)„d)e/ƒZ5d*d+„Z6ddl7Z7e7j8d,ƒZ9[7d-d.„Z:d/d0„Z;Gd1d2„d2e/ƒZGd7d8„d8e/ƒZ?Gd9d:„d:ƒZ@d;d<„ZAGd=d>„d>e?ƒZBGd?d@„d@eBƒZCGdAdB„dBƒZDeDƒZEGdCdD„dDƒZFeFƒZGGdEdF„dFe/ƒZHd»dGdH„ZIdIZJGdJdK„dKe/ƒZKGdLdM„dMeKƒZLGdNdO„dOe/ƒZMGdPdQ„dQe/ƒZNGdRdS„dSe/ƒZOGdTdU„dUe/ƒZPGdVdW„dWe/ƒZQGdXdY„dYe/ƒZRGdZd[„d[e/ƒZSGd\d]„d]eSƒZTGd^d_„d_eSƒZUGd`da„dae ƒZVGdbdc„dceSƒZWGddde„deeSƒZXdfdg„ZYdhZZGdidj„dje/ƒZ[Gdkdl„dle/ƒZ\Gdmdn„dne/ƒZ]d¼dodp„Z^dqZ_Gdrds„dse/ƒZ`Gdtdu„due/ƒZaGdvdw„dweaƒZbGdxdy„dyeaƒZcGdzd{„d{eaƒZdGd|d}„d}edƒZed~d„ZfGd€d�„d�e/ƒZgGd‚dƒ„dƒe/ƒZhGd„d…„d…e/ƒZiGd†d‡„d‡e/ƒZjGdˆd‰„d‰e/ƒZkGdŠd‹„d‹ekƒZlGdŒd�„d�e/ƒZmGdŽd�„d�emƒZnGd�d‘„d‘e/ƒZoGd’d“„d“eoƒZpGd”d•„d•e/ƒZqGd–d—„d—e/ƒZrGd˜d™„d™e/ƒZsGdšd›„d›esƒZtGdœd�„d�e/ƒZuGdždŸ„dŸe/ƒZvd d¡d¢d£œZwGd¤d¥„d¥e/ƒZxGd¦d§„d§ƒZyGd¨d©„d©e/ƒZzGdªd«„d«ezƒZ{Gd¬d­„d­ezƒZ|Gd®d¯„d¯e/ƒZ}Gd°d±„d±e}ƒZ~Gd²d³„d³e}ƒZGd´dµ„dµe}ƒZ€e�d¶k�rte‚d·ƒdS)½z3.4.1a_ 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@s eZdZdS)ÚPDFErrorN)Ú__name__Ú __module__Ú __qualname__©rrú9/tmp/tmp4i9tl1d3/lib64/python/reportlab/pdfbase/pdfdoc.pyrsrÚ__InternalName__Ú __RefOnly__Ú __Comment__Ú BasicFontsÚPagesééé)Z transparencycCst|tƒr|jdƒS|S)NZ extpdfdoc)Ú isinstanceÚstrÚencode)ÚxrrrÚ pdfdocEnc5sr(cCs¬t|tƒrd| r*t|tƒr*|j|ƒj|ƒS|j|ƒ}tj r^tjr^t|t ƒr^t d|j ƒ|}|SnDt |ƒt t fkr€t t|ƒƒSt|ƒrŒ|St|ƒrœt |ƒSt t|ƒƒSdS)z„Indirection step for formatting. Ensures that document parameters alter behaviour of formatting for all elements. z%% %s N)r$Ú PDFObjectÚhasattrrÚ ReferenceÚformatrÚ invariantÚ pdfCommentsrr(ÚtypeÚfloatÚintrrr r%)ÚelementÚdocumentÚtoplevelÚfrrrr,8s   r,cCsd|S)Nz FormXob.%sr)Ú externalnamerrrÚ xObjectNameRsr7c@s,eZdZdd„Zdd„Zdd„Zdd„Zd S) Ú NoEncryptioncCs|S)zencode a string, stream, textr)ÚselfÚtrrrr&ZszNoEncryption.encodecCsdS)Nr)r9r3rrrÚprepare]szNoEncryption.preparecCsdS)Nr)r9ZobjnumÚversionrrrÚregister`szNoEncryption.registercCsdS)Nr)r9rrrÚinfocszNoEncryption.infoN)rrrr&r;r=r>rrrrr8Ysr8c@s eZdZdS)r)N)rrrrrrrr)gsr)c@seZdZdZeƒZdS)ÚDummyDocz'used to bypass encryption when requiredN)rrrÚ__doc__r8Úencryptrrrrr?jsr?c@s4eZdZdZeƒZdejejde dfdd„Z dd„Z dd„Z d d „Z d d „Zd d„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Z d1d2„Z!d3d4„Z"d5d6„Z#d7d8„Z$d9d:„Z%d;d<„Z&dFd>d?„Z'd@dA„Z(dBdC„Z)dGdDdE„Z*dS)HÚ PDFDocumentNrc Cs.d|_d|_d|_d|_d|_|dkr0tj|_n||_|j|ƒ||_t ƒ}|_ |j dƒt |jƒ|_ |j j}t|ƒ}|j t|ƒƒi|_i|_i|_i|_tƒ}|_|_tƒ} |_| |_|rÊ|ntj}|rÞt|ƒ|_|rètƒntƒ|_|_ |_ t!ƒ|_"i|_#t$iƒ} d| _%|j&| t'ƒg|_(dS)Nrr!sa reportlab documentzThe standard fonts dictionary))Ú_IDÚ objectcounterÚshadingCounterÚinObjectÚ pageCounterrr-ÚsetCompressionÚ _pdfVersionrÚ signatureÚupdaterÚ _timeStampr:Úasciir ÚidToObjectNumberAndVersionÚ idToObjectÚ idToOffsetÚ numberToIdÚ PDFCatalogÚCatalogÚ_catalogÚPDFPagesr Z documentLangÚ PDFStringÚLangÚ PDFOutlines0Ú PDFOutlinesÚoutlineÚOutlinesÚPDFInfor>Ú fontMappingÚ PDFDictionaryrr+rÚ delayedFonts) r9Z dummyoutlineÚ compressionr-ÚfilenameÚ pdfVersionÚlangÚsigÚcatÚpagesÚDDrrrÚ__init__ssB        zPDFDocument.__init__cCs ||_dS)N)r`)r9ÚonoffrrrrH¨szPDFDocument.setCompressioncGs$x|D]}t|jt|ƒ|_qWdS)zREnsure that the pdf version is greater than or equal to that specified by the keysN)ÚmaxrIÚPDF_SUPPORT_VERSION)r9ÚkeysÚkrrrÚensureMinPdfVersion¬s zPDFDocument.ensureMinPdfVersioncCs|jr dS|jjt|ƒƒdS)z add information to the signatureN)rCrJrKr )r9ÚthingrrrÚupdateSignature±szPDFDocument.updateSignaturecCsF|jr |jS|jjƒ}tƒ}t|dd�j|ƒ}d||d|_|jS)zz <%s@0X%8.8X>r!Úwbz#Cannot use %s as a filename or fileÚlatin1Zmac)Ú markfilenameZ _verbosityzsaved %s)ÚgetattrÚ RuntimeErrorÚ __class__rrwr*r$r1r ÚidrÚopenÚ TypeErrorÚreprÚ GetPDFDatar r&rxÚcloseÚosrzÚreportlab.lib.utilsr}Úprint)r9raÚcanvasZmyfiler5Údatar‡r}rrrÚ SaveToFileÀs:           zPDFDocument.SaveToFilecCstx|jD]}|j|ƒqW|j|j_|jj|jƒ|j|jƒ|j|jƒ|jj ||ƒ|jj dkrld|j_|j ƒS)Nr) r_Ú addObjectsr-r>rsrJr+rSr[r;Úreadyr,)r9rŠZfntrrrr…às     zPDFDocument.GetPDFDatacCs0|jdk r&|jdkrdStd|jƒ‚d|_dS)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)rFÚ ValueError)r9rrrÚinPageðs   zPDFDocument.inPagecCs d|_dS)zBspecify that we are in a form xobject (disable page features, etc)ÚformN)rF)r9rrrÚinForm÷szPDFDocument.inFormc Csr|j}||kr||Sy2tj|ƒ}|jr8tdt|ƒƒ‚|j|ƒ||Stk rltdt|ƒƒ‚YnXdS)Nz1getInternalFontName(%s) called for a dynamic fontzFont %s not known!)r]rZgetFontZ _dynamicFontrr„r�ÚKeyError)r9Z psfontnameZfmZfontObjrrrÚgetInternalFontNameÿs  zPDFDocument.getInternalFontNamecCsdt|jƒS)NÚPage)r„rG)r9rrrÚ thisPageNameszPDFDocument.thisPageNamecCs t|jƒƒS)N)ÚPDFObjectReferencer—)r9rrrÚ thisPageRefszPDFDocument.thisPageRefcCs8|jƒ}|j||ƒ|jj|ƒ|jd7_d|_dS)Nr!)r—r+r ÚaddPagerGrF)r9r�rzrrrršs   zPDFDocument.addPagecCs,|jdkr|jƒ|j|t|ƒƒd|_dS)zadd a Form XObject.r’N)rFr“r+r7)r9rzr’rrrÚaddForms zPDFDocument.addFormcCsd|S)NzAnnot.%sr)r9r6rrrÚannotationName#szPDFDocument.annotationNamecCs|j||j|ƒƒdS)N)r+rœ)r9rzÚ annotationrrrÚ addAnnotation&szPDFDocument.addAnnotationcCs|j|ƒ}t|ƒS)N)rœr˜)r9rzÚ internalnamerrrÚ refAnnotation)s zPDFDocument.refAnnotationcCs(d|j}|j||ƒ|jd7_|S)NzSh%dr!)rEr+)r9ZshadingrzrrrÚ addShading-s  zPDFDocument.addShadingcCsð|j}|s¶|jdkr.|jdkr.|jdkr.d}nj|jdkrR|jdkrR|jdkrRd}nF|jdkrv|jdkrv|jdkrvd}n"|jdkr˜|jdkr˜|jdkr˜d}|sªtd|ƒ‚n |j|d�}t|ƒdd…}||jkrèt |ƒj ƒ}|j ||ƒ||fS) NrZBLACKZCYANZMAGENTAZYELLOWz&CMYK colour %r used without a spotName)ÚspotNamer!) r¢ZcyanZmagentaZyellowZblackr�ÚcloneÚPDFNamerOÚPDFSeparationCMYKColorÚvaluer+)r9ÚcmykZsnamerzÚseprrrÚaddColor3s$    zPDFDocument.addColorcCs|dkrd|j_n||j_dS)zembeds in PDF fileNz (anonymous))r>Útitle)r9rªrrrÚsetTitleHs zPDFDocument.setTitlecCs|dkrd|j_n||j_dS)zembedded in PDF fileNz (anonymous))r>Úauthor)r9r¬rrrÚ setAuthorOs zPDFDocument.setAuthorcCs|dkrd|j_n||j_dS)zembeds in PDF fileNz (unspecified))r>Úsubject)r9r®rrrÚ setSubjectWs zPDFDocument.setSubjectcCs|dkrd|j_n||j_dS)zembeds in PDF fileNz (unspecified))r>Úcreator)r9r°rrrÚ setCreator`s zPDFDocument.setCreatorcCs|dkrt|j_n||j_dS)zembeds in PDF fileN)Ú_default_producerr>Úproducer)r9r³rrrÚ setProducergs zPDFDocument.setProducercCs|dkrd|j_n||j_dS)z/embeds a string containing keywords in PDF fileNÚ)r>Úkeywords)r9r¶rrrÚ setKeywordsns zPDFDocument.setKeywordscCs ||j_dS)N)r>Ú_dateFormatter)r9Ú dateFormatterrrrÚsetDateFormatterwszPDFDocument.setDateFormattercCsHt|jjƒƒ}ddlm}x |jD]}||kr"|j|ƒq"W|jƒ|S)Nr)Ú _fontdata)Úlistr]rlÚreportlab.pdfbaser»Z standardFontsÚappendÚsort)r9Z fontnamesr»rzrrrÚgetAvailableFontszs  zPDFDocument.getAvailableFontsc CsÖ|jj|ƒ|j}|j}|j|ƒ|j|ƒd}|jjƒ}|rH|j|ƒ}d}g}|j}|j}|j} |j} t |j ƒ|_ } x¤|d7}||krŒP||} | | } t | | ƒ}|j |ƒ}tj rþtjrþy | jj}Wnt| ƒ}YnX| jdt| ƒ|dd…fƒ| j|ƒ}|| | <|j| ƒqzW|` t|ƒ}|d|k�rHtd||fƒ‚tƒ}|jd|ƒ|j |ƒ}| j|ƒ}t||d|j|ƒ|j|ƒ||jƒd�}|j |ƒ}| j|ƒx t|dgƒD]}|j| ƒ�q¸W| j |ƒS)Nrr!z%% %s: class %s é2z3counter %s doesn't match number to id dictionary %s)Ú startxrefÚSizeÚRootÚInfoÚEncryptrvZ _digiSigs)rAr;rSr>r+rQrNrOrPÚPDFFilerIZ __accum__ÚPDFIndirectObjectr,rr-r.r€rrMÚaddr¾Úlenr�ÚPDFCrossReferenceTableÚ addsectionÚ PDFTrailerrvr~Úsign)r9rer>Z encryptrefZ encryptinfoÚcounterÚidsZ numbertoidÚidToNVZidToObZidToOfZFileÚoidÚobjZIOZIOfÚ classnameÚoffsetÚlnoZxrefZxreffZ xrefoffsetÚtrailerZtrailerfZdsrrrr,„sj               zPDFDocument.formatcCst|ƒ}||jkS)z test for existence of named form)r7rO)r9rzrŸrrrÚhasFormÉszPDFDocument.hasFormÚMediaBoxcCsrt|ƒ}||jkrn|j|}t|dƒr0|j|St|tƒrB|jƒSt|tƒr^t|j j |j ƒSt dt |ƒƒ‚dS)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)r7rOr*rÚr$ÚPDFFormXObjectÚBBoxListÚ PDFStreamr¼Ú dictionaryÚdictÚsequencer�r„)r9rzZboxTyperŸZtheformrrrÚ getFormBBoxÎs      zPDFDocument.getFormBBoxcCst|ƒS)ziLets canvas find out what form is called internally. Never mind whether it is defined yet or not.)r7)r9rzrrrÚgetXObjectNameàszPDFDocument.getXObjectNamecCs2i}x$|D]}t|ƒ}t|ƒ}|||<q Wt|ƒS)z…construct an xobject dict (for inclusion in a resource dict, usually) from a list of form names (images not yet supported))r7r˜r^)r9Z formnamesÚDrzrŸÚ referencerrrÚxobjDictås   zPDFDocument.xobjDictcCst|tƒ}|j}|dkr,| s(|jtkr,|St|tƒrŒ|j}|dk rd||krdtdt|ƒt|ƒfƒ‚||kr„tdt |ƒt |ƒfƒ‚t|ƒS|j d}|_ |dkr°dt|ƒ}||krà||}||krØtdt|ƒƒ‚t|ƒS|rê||_|df|j |<||j |<|||<t|ƒS)Nz0attempt to reregister object %s with new name %sz1object of type %s named as %s, but not registeredr!ÚRzredefining named object: r)r$r)rOr€r˜r*rr�r„r/rMrDrNrQ)r9rÓrzZiobrOZintnamerDÚotherrrrr+ðs4    zPDFDocument.Reference)rÙ)N)+rrrÚdefaultStreamFiltersr8rArZpageCompressionr-ÚPDF_VERSION_DEFAULTrhrHrnrprvrŒ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+rrrrrBosP /     E  rBÚtrueÚfalseZnullc@s&eZdZd dd„Zdd„Zdd„ZdS) rtúutf-8cCs||_||_dS)N)r:rr)r9r:rrrrrrhszPDFText.__init__cCs8|j}t|ƒr|j|jƒ}tj|jj|ƒƒ}d|dS)Nó<ó>)r:r r&rrÚbinasciiÚhexlifyrA)r9r3r:Úresultrrrr,s  zPDFText.formatcCstƒ}|j|ƒS)N)r?r,)r9ZdummydocrrrÚ__str__ szPDFText.__str__N)rì)rrrrhr,ròrrrrrts rtcCs|S)Nr)ÚnrrrÚ PDFnumber$srôz[^()]cCsRtjd|ƒ}d}x2|D]*}|dkr,|d7}q|d8}|dkrdSqW| rNdpPdS)z+test whether a string is balanced in parensrµrú(r!)Ú_re_cleanparensÚsub)ÚsróÚcrrrÚ _isbalanced*s   rúcCs4y|jdƒdStk r.}zdSd}~XnXdS)z(return true if no Pdfdoc encoding errorsÚpdfdocr!rN)r&ÚUnicodeEncodeError)ZutextÚerrrÚ _checkPdfdoc5s  rþc@s*eZdZdZd dd„Zdd„Zdd „Zd S) rVFr!ÚautocCs:t|tƒr$|j|_|j|_|j|_n||_||_||_dS)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$rVrøÚescaperr)r9rørrrrrrrh?s  zPDFString.__init__cCsî|j}t|ddƒ}t|ƒrÆ|dkrÄyb|jtjƒr<|jdƒ}n"|jtjƒrT|jdƒ}n |jdƒ}t|ƒrr|j dƒ}ntj|j dƒ}Wn>y|jdƒWn"t j dt |ƒfƒ‚YnXYnXnpt |ƒ�r&|dkrþt|ƒrì|j dƒ}ntj|j dƒ}n&|j�r|j |jƒ}ntj|j dƒ}ntdt|ƒƒ‚t|d d ƒ}t|jtƒ�s`|jj |ƒ}d }|�rÞyd t|ƒ}Wn td |t |ƒfƒ‚YnX|d @�r®|jddƒ}|d@�rÖt|ƒ�rÖ|jddƒjddƒ}t|ƒSd|dSdS)NrrrÿÚ utf_16_beÚ utf_16_leÚutf8rûz Error in %sz-PDFString argument must be str/unicode not %srr!z(%s)zcannot escape %s %séz\012Ú r#z\(rõz\)ú)ó(ó))rør~rÚ startswithÚcodecsÚ BOM_UTF16_BEÚdecodeÚ BOM_UTF16_LErþr&rrxr„r ÚunicodeEncValidrrr�r/r$rAr8rÚreplacerúr()r9r3rørrÚurÚesrrrr,OsV             zPDFString.formatcCsdt|jƒS)Nz(%s))rrø)r9rrrròƒszPDFString.__str__N)r!rÿ)rrrrrhr,ròrrrrrV=s 4rVé!é~cCs`t|ƒ}xHt|ƒD]<\}}||ks2||ks2|dkrdtt|ƒƒdd…||<qWddj|ƒS)Nz %()<>{}[]#ú#rú/rµ)r¼Ú enumerateÚhexÚordÚjoin)r‹ÚloÚhiÚLÚirùrrrr¤†s  r¤c@sTeZdZdZddd„Zdd„Zdd„Zd d „Zd d „Zddd„Z dd„Z dd„Z dS)r^TNcCs|dkri|_n |jƒ|_dS)zPdict should be namestring to value eg "a": 122 NOT pdfname to value NOT "/a":122N)rßÚcopy)r9rßrrrrh’szPDFDictionary.__init__cCs||j|<dS)N)rß)r9rzr¦rrrÚ __setitem__˜szPDFDictionary.__setitem__cCs |j|S)N)rß)r9ÚarrrÚ __getitem__šszPDFDictionary.__getitem__cCs ||jkS)N)rß)r9r rrrÚ __contains__œszPDFDictionary.__contains__cCs|j|j|ƒ|j|<dS)N)r+rß)r9rzr3rrrr+žszPDFDictionary.Referenceó c s¾|j‰ytˆjƒƒ}Wnttˆƒƒ‚YnXtˆtƒsD|jƒ‡‡fdd„|Dƒ}|jrdt j sn|jdkrz|j |ƒ}n8|j }x&t tdt|ƒdƒƒD]}||dƒq–Wdj |ƒ}d|dS) Ncs,g|]$}tt|ƒˆƒdtˆ|ˆƒ‘qS)ó )r,r¤)Ú.0rm)rßr3rrú ¨sz(PDFDictionary.format..Úforcedés r$s<< s >>)rßr¼rlr‰rMr$rr¿Ú multilinerÚ pdfMultiLinerÚinsertÚreversedÚrangerÊ)r9r3ÚINDrlrr:rr)rßr3rr, s     zPDFDictionary.formatcCs t|jƒS)N)r^rß)r9rrrr³szPDFDictionary.copycCs@|j}dd„|jƒDƒ}x"|D]}|j|ƒ||dd…<qWdS)NcSsg|]}|jdƒr|‘qS)r)r )r%rmrrrr&¹sz+PDFDictionary.normalize..r!)rßrlÚpop)r9rãÚKrmrrrÚ normalize¶s zPDFDictionary.normalize)N)r#) rrrr)rhrr!r"r+r,rr1rrrrr^�s  r^c@seZdZdd„Zdd„ZdS)Ú checkPDFNamescGsttt|ƒƒ|_dS)N)r¼Úmapr¤Únames)r9r4rrrrh¾szcheckPDFNames.__init__cCs$|jdƒst|ƒ}||jkr |SdS)Nr)r r¤r4)r9r¦rrrryÀs  zcheckPDFNames.__call__N)rrrrhryrrrrr2½sr2cCs|dkr |SdS)Nrêrë)rêrër)r¦rrrÚcheckPDFBooleanÆsr5c@s"eZdZiZddd„Zdd„ZdS)ÚCheckedPDFDictionaryNcCstj||ƒ|r||_dS)N)r^rhÚvalidate)r9rßr7rrrrhËs zCheckedPDFDictionary.__init__cCsN||jkrtd|ƒ‚|j||ƒ}|dkrrDrrrr&ùs  z"PDFStreamFilterBase85Encode.encodecCst|ƒS)N)r)r9r>rrrr ÿsz"PDFStreamFilterBase85Encode.decodeN)rrrrAr&r rrrrrB÷srBc@s&eZdZdZdZddd„Zdd„ZdS) rÝz@set dictionary elements explicitly stream.dictionary[name]=valuer!NcCs$|dkrtƒ}||_||_||_dS)N)r^rÞÚcontentÚfilters)r9rÞrErFrrrrh s zPDFStream.__init__c CsØ|j}t|jjƒƒ}|j}|j}|jdkr2tdƒ‚|dkr@|j}|dk rœd|jkrœt|ƒ}|j ƒg}x(|D] }|j |ƒ}|j dt |j ƒƒqlWt|ƒ|d<|jj |ƒ}t||ƒ}t|ƒ|d<t||ƒ} | d|dS)Nzstream content not setÚFilterrÚLengths stream s endstream )rÞr^rßrrErFr�rèr¼Úreverser&r+r¤rAÚPDFArrayrAr,rÊ) r9r3rÞrErFZrfÚfnamesr5ZfcÚfdrrrr,s*        zPDFStream.format)NNN)rrrr@rrhr,rrrrrÝs rÝcCs>|dkr t}|jƒd}t|tjr*ttgp.tgd�}d|_|S)Nr)rErFz test stream)ÚteststreamcontentÚstriprÝrÚuseA85ÚPDFBase85EncodeÚ PDFZCompressr)rEÚSrrrÚ teststream/s rSz\ 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@s*eZdZdZdd„Zdd„Zd dd„Zd S) rJTcCst|ƒ|_dS)N)r¼rà)r9ràrrrrhAszPDFArray.__init__cCstt|j|jƒƒ|_dS)z'make all objects in sequence referencesN)r¼r3r+rà)r9r3rrrÚ ReferencesCszPDFArray.Referencesó cs’‡fdd„|jDƒ}|jr tjs*|jdkr6|j|ƒ}nPt|ƒ}|dkr||j}x"ttd|dƒƒD]}||dƒq^Wdj|ƒ}n dj|ƒ}d|dS) Ncsg|]}t|ˆƒ‘qSr)r,)r%rý)r3rrr&Gsz#PDFArray.format..r'é s r$s[ s ]) ràr)rr*rrÊr+r,r-)r9r3r.rrór:rr)r3rr,Fs   zPDFArray.formatN)rU)rrrr)rhrTr,rrrrrJ?srJc@seZdZdZdS)ÚPDFArrayCompactFN)rrrr)rrrrrWVsrWc@s eZdZdZdd„Zdd„ZdS)rÈr!cCs||_||_dS)N)rzrE)r9rzrErrrrh[szPDFIndirectObject.__init__cCs\|j}|j|\}}|jj||ƒt|j|dd�}td||fƒ||jdƒrRdnddS)Nr!)r4z %s %s obj ó ósendobj )rzrNrAr=r,rEr(Úendswith)r9r3rzróÚvZfcontentrrrr,^s zPDFIndirectObject.formatN)rrrrrhr,rrrrrÈYsrÈc@seZdZdd„Zdd„ZdS)r˜cCs ||_dS)N)rz)r9rzrrrrhiszPDFObjectReference.__init__c Cs8ytd|j|jƒStdt|jƒƒ‚YnXdS)Nz%s %s Rz:forward reference to %s not resolved upon final formatting)r(rNrzr”r„)r9r3rrrr,kszPDFObjectReference.formatN)rrrrhr,rrrrr˜hsr˜c@s0eZdZefdd„Zdd„Zdd„Zdd„Zd S) rÇcCs0g|_|jj|_d|_|jtd|ƒdƒdS)Nrz %%PDF-%s.%ssA %“Œ‹ž ReportLab Generated PDF document http://www.reportlab.com )Ústringsr¾rxrÕrÉr()r9rbrrrrhss  zPDFFile.__init__cCsdS)Nr)r9rrrÚ closeOrReset�szPDFFile.closeOrResetcCs*t|ƒ}|j}|t|ƒ|_|j|ƒ|S)zGshould be constructed as late as possible, return position where placed)r(rÕrÊrx)r9rørñrrrrÉ„s  z PDFFile.addcCs dj|jƒS)NrY)rr\)r9r3rrrr,ŒszPDFFile.formatN)rrrrérhr]rÉr,rrrrrÇqs rÇc@seZdZdd„Zdd„ZdS)ÚPDFCrossReferenceSubsectioncCs||_||_dS)N)ÚfirstentrynumberÚ idsequence)r9r_r`rrrrh�sz$PDFCrossReferenceSubsection.__init__cCs|j}|j}t|ƒ}t|ƒ}i}|dkrDd|d<|d}|jddƒ|j}|j}||d} xˆ|D]€} || \} } | |kr˜td| t| ƒt|| ƒfƒ‚| | ks¨| |krºtd| || fƒ‚| |} | || <|| }d|| f|| <qbWd||f}|jd|ƒ|j d ƒt d j |ƒƒS) z`id sequence should represent contiguous object nums else error. free numbers not supported (yet)rzstandard free entryr!z0000000000 65535 f z object number collision %s %s %sz$object number %s not in range %s..%sz%0.10d %0.5d n z%s %srµr) r_r`r¼rÊr+rNrPr�r„r¾r(r)r9r3r_r`ÚentriesZnentriesZtakenrÑrPZlastentrynumberr�Únumr<ZrnumrÕÚ firstlinerrrr,“s4       z"PDFCrossReferenceSubsection.formatN)rrrrhr,rrrrr^�sr^c@s$eZdZdd„Zdd„Zdd„ZdS)rËcCs g|_dS)N)Úsections)r9rrrrhµszPDFCrossReferenceTable.__init__cCst||ƒ}|jj|ƒdS)N)r^rdr¾)r9Z firstentryrÐÚsectionrrrrÌ·s z!PDFCrossReferenceTable.addsectioncCsJ|j}|stdƒ‚dg}x"|jD]}t||ƒ}|j|ƒq Wtdj|ƒƒS)Nzno crossref sectionssxref rY)rdr�r,r¾r(r)r9r3rdrrøÚfsrrrr,ºs  zPDFCrossReferenceTable.formatN)rrrrhrÌr,rrrrrË´srËc@seZdZddd„Zdd„ZdS)rÍNc Csz||_|dks|dkrtdƒ‚tƒ}|_xDd|fd|fd|fd|fd|fd|fgD]\} } | dk rT| || <qTWd|_dS) NzSize and Root keys requiredrÃÚPrevrÄrÅrvrÆr')rÂr�r^rßr)) r9rÂrÃrgrÄrÅrvrÆrßrór[rrrrhÅs  zPDFTrailer.__init__cCs.|jj|dd�}djd|dtt|jƒƒdgƒS)NrX)r.rYstrailer s startxref s %%EOF )rßr,rr(r%rÂ)r9r3Zfdictrrrr,Ïs zPDFTrailer.format)NNNNNN)rrrrhr,rrrrrÍÄs rÍc@sdeZdZdZdZedƒedƒddœZdjƒZeZ dd „Z d d „Z d d „Z dd„Z dd„Zdd„ZdS)rRz Document Rootr!rSZUseNoneN)ÚTypeÚPageModerWz¡ Dests Outlines Pages Threads AcroForm Names OpenAction PageMode URI ViewerPreferences PageLabels PageLayout JavaScript StructTreeRoot SpiderInfocCs²|j|ƒ|j}|j}i}x0|jƒD]$\}}t|||ƒ}|dk r$|||<q$Wx*|jD] }t||dƒ}|dk rT|||<qTWx&|D]}||kr~|j||ƒ||<q~Wt|ƒ}t||ƒS)N) Ú check_formatÚ __Defaults__Ú__Refs__Úitemsr~Ú __NoDefault__r+r^r,)r9r3ÚdefaultsZRefsrãrmr[rßrrrr,ìs"       zPDFCatalog.formatcCs|jdƒdS)NZ UseOutlines)Ú setPageMode)r9rrrÚ showOutlineszPDFCatalog.showOutlinecCs|jdƒdS)NZ FullScreen)rp)r9rrrÚshowFullScreenszPDFCatalog.showFullScreencCs|rt|ƒ|_dS)N)r¤Z PageLayout)r9ZlayoutrrrÚ setPageLayoutszPDFCatalog.setPageLayoutcCs|rt|ƒ|_dS)N)r¤ri)r9Úmoderrrrp szPDFCatalog.setPageModecCsdS)zfor use in subclassesNr)r9r3rrrrjszPDFCatalog.check_format)rrrrrr¤rkr9rnrlr,rqrrrsrprjrrrrrRßsrRc@sReZdZdZdZdZdedƒiZdjƒZ dgZ dd „Z d d „Z d d „Z dd„ZdS)rUzHPAGES TREE WITH ONE INTERNAL NODE, FOR "BALANCING" CHANGE IMPLEMENTATIONz page treer!rhr zKids Count ParentÚParentcCs g|_dS)N)rf)r9rrrrhszPDFPages.__init__cCs |j|S)N)rf)r9Úitemrrrr!szPDFPages.__getitem__cCs|jj|ƒdS)N)rfr¾)r9r�rrrrš szPDFPages.addPagecCs,|j}t|ƒ}|j|ƒ||_t|ƒ|_dS)N)rfrJrTZKidsrÊÚCount)r9r3rfZkidsrrrrj"s  zPDFPages.check_formatN)rrrr@rrr¤rkr9rnrlrhr!ršrjrrrrrUs rUc@s€eZdZdZdZdZdedƒiZdjƒZ djƒZ dZ d Z d Z dZdZd ZiZiZd Zd d „Zd d„Zdd„Zdd„Zdd„Zd S)ÚPDFPagezPage dictionaryrr!rhr–z³Parent MediaBox Resources Contents CropBox Rotate Thumb Annots B Dur Hid Trans AA PieceInfo LastModified SeparationInfo ArtBox TrimBox BleedBox ID PZ TranszContents Parent IDiSiJNcCs x|jD]}t||dƒqWdS)N)rnÚsetattr)r9rzrrrrhEs zPDFPage.__init__cCs ||_dS)N)r`)r9rirrrrHIszPDFPage.setCompressioncCs.|jrtdƒ‚t|ƒr$dj|ƒd}||_dS)Nz&overridden! must set stream explicitlyr)ÚOverride_default_compilationr�rrÚstream)r9ÚcoderrrÚ setStreamKs zPDFPage.setStreamcCst|ƒ|_dS)N)r^ÚTrans)r9ZtranDictrrrÚsetPageTransitionRszPDFPage.setPageTransitioncCs<|jr dS|jp.z- !!!!! Duplicate PageLabel seen for pages %rcsg|]}ˆj|ƒdkr|‘qS)r!)Úcount)r%r')Útmprrr&£s) r–r¿r“Úsortedr r¼Úsetr¾rJr•rRr,)r9r3r–r�r—r)ršrr,žs(  zPDFPageLabels.format) rrrZ __comment__rrkrnrlrhr˜r,rrrrr”„sr”c@sJeZdZdZdZiZdjƒZdZdZ dZ dZ dZ d Z dd d „Zd d „ZdS)Ú PDFPageLabelNrz Type S P Stz:ARABIC ROMAN_UPPER ROMAN_LOWER LETTERS_UPPER LETTERS_LOWERrãræÚrÚAr cCsJ|r*|jƒ|jkr t||jƒƒ}t|ƒ|_|r8t|ƒ|_|rFt|ƒ|_dS)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¤rRrôZStrVÚP)r9ÚstyleÚstartÚprefixrrrrh¹s2  zPDFPageLabel.__init__cCstjr tƒ‚dS)NF)rZerrorOnDuplicatePageLabelPager“)r9ZothrrrÚ__lt__ñszPDFPageLabel.__lt__)NNN)rrrrrrkr9rnr¡ZARABICZ ROMAN_UPPERZ ROMAN_LOWERZ LETTERS_UPPERZ LETTERS_LOWERrhr¦rrrrr�¬s 8r�cCs\tƒ}tƒ|_|j}|j|ƒ|_tddddgƒ|_tƒ}|j ƒ|j ƒ||_ |j |ƒdS)NriSiI) rxrSr…r r+rurJrÙr‡rŠrˆr†rš)r3r¢rfr’rrrÚtestpage÷s r§z/ << /Count 0 /Type /Outlines >>c@s(eZdZdZejddƒZdZdd„ZdS)rXz TEST OUTLINE!rr!cCs t|jƒS)N)r(r>)r9r3rrrr,szPDFOutlines0.formatN) rrrrÚ DUMMYOUTLINErr>rr,rrrrrX s rXc@s8eZdZdZdZZZZZZ Z Z dd„Z dS)ÚOutlineEntryObjectzan entry in an outlineNcCs`i}t|jƒ|d<|j|d<|j|d<x&d D]}t||ƒ}|dk r,|||<q,Wt|ƒ}|j|ƒS) NÚTitleruÚDestrgÚNextÚFirstÚLastrw)rgr¬r­r®rw)rVrªrur«r~r^r,)r9r3rãrór[ÚPDrrrr,s     zOutlineEntryObject.format) rrrr@rªr«rurgr¬r­r®rwr,rrrrr©s r©c@sleZdZdZdZZdZdZdd„Zddd„Z d d „Z d d „Z d d„Z dd„Z dd„Zdd„Zddd„ZdS)rYaø 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. Nrr!cCs"i|_i|_g|_g|_i|_dS)N)ÚdestinationnamestotitlesÚdestinationstotitlesÚ levelstackÚ buildtreeÚ closedict)r9rrrrh:s zPDFOutlines.__init__c CsL|dkr|dkrtdƒ‚t|tƒs2tdt|ƒƒ‚|dkrBtdƒ‚|dkrN|}|j}|j}|j}||krž||dkrˆtd||||fƒ‚|d}}|jgƒxl||k�r |d }|d =|d } | d } t| tƒrì| \} } tdt | ƒƒ‚n| } |} | | f| d <|d}q W|dk�rdS|dj|ƒ||j |<|�rBd|j |<||_dS)z/destinationname of None means "close the tree" Nrzclose tree must have level of 0zlevel must be integer, got %sznegative levels not allowedr!z_can't jump from outline level %s to level %s, need intermediates (destinationname=%r, title=%r)z cannot reset existing sections: éÿÿÿÿrµrµrµrµrµ) r�r$r1r/Ú currentlevelr²r³r¾Útupler„r°r´) r9ZdestinationnameÚlevelrªÚclosedr¶ÚstackÚtreeÚcurrentZpreviousZlastinpreviousrzZ sectionlistrrrÚaddOutlineEntryAsF           zPDFOutlines.addOutlineEntrycCs ||_dS)N)Úmydestinations)r9ÚdestinationtreerrrÚsetDestinationsfszPDFOutlines.setDestinationscCs@i}tdƒ|d<|j|d<|j|d<|j|d<t|ƒ}|j|ƒS)Nr[rhrwr­r®)r¤r™ÚfirstÚlastr^r,)r9r3rãr¯rrrr,is    zPDFOutlines.formatcGs|j||ƒ}|j|ƒdS)N)ÚtranslateNamesrÀ)r9rŠÚnametreeÚdesttreerrrÚsetNamesss zPDFOutlines.setNamescCs|j||ƒ}|j|ƒdS)z1Explicit list so I don't need to do in the callerN)rÃrÀ)r9rŠrÄrÅrrrÚ setNameListws zPDFOutlines.setNameListc CsÐ|j}|j}|j}t|ƒrzt|ƒs,|jdƒ}|j|ƒ}|}||krL||}n|||<|||<||krld||<||j|ƒiSt|ƒr¼g}x|D]} |j|j || ƒƒqŒWt |t ƒr¸t |ƒS|St dt |ƒƒ‚dS)z=recursively translate tree of names into tree of destinationsrr!z5in outline, destination name must be string: got a %sN)r°r±r´r r r Z_bookmarkReferencerr¾rÃr$r·rƒr/) r9rŠÚobjectr°r±r´Z destinationrªrÚorrrrÃ|s.     zPDFOutlines.translateNamescCs„|jdkrP|jr4|jdƒ|jd}|j||ƒ|_nd|_|_d|_d|_dSt|j|jƒ|_|j ||jdd�\|_|_d|_dS)zPprepare all data structures required for save operation (create related objects)Nrr!)r4rµ) r¾r²r½rÃrÁrÂr™rŽr´Úmaketree)r9r3rŠZ destnamesrrrr;—s    zPDFOutlines.preparecCsÆ|rd}|j|jƒ}n(|jd7_d|j}|dkr>tdƒ‚t|ƒsNtdƒ‚t|ƒ}|d}d}} } |j} |j} �xDt|ƒD�]6} t ƒ}||_ d|| f}|j||ƒ}|dk rÀ||_ | |_ | dkrÌ|} |} |}|} || }t |tƒrð|}njt |tƒ�rJy |\}}Wntdt|ƒƒ‚YnXt|| ƒ|_|j|||ƒ\|_|_ntdt|ƒƒ‚yt|jƒƒ\\}}Wntd t|ƒƒ‚YnX| ||_||_t |tƒr‚|| kr‚|j |_q‚W| | fS) NZOutliner!z Outline.%sz2non-top level outline elt parent must be specifiedz-destinationtree must be list or tuple, got %sz%s.%sz7destination 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 )r+r[r™r�rrÊr°r´r-r©rur¬rgr$rßr·rwrÊr­r®r/r¼rmr rªr«)r9r3r¿rur4Ú levelnameZneltsÚ lastindexZlasteltZfirstrefZlastrefr°r´ÚindexZeltobjZeltnameZeltrefÚeltÚleafdictÚ subsectionsrªr«rrrrÊ«s^         zPDFOutlines.maketreerµ)rNN)Nr)rrrr@r¾rŽrÏr¶rhr½rÀr,rÆrÇrÃr;rÊrrrrrY"s % rYcCsjt|tƒr4|\}}t|jƒƒ\\}}|r4||kr4dSt|ƒrfg}x|D]}|jt||ƒƒqFWt|ƒSdS)zButility for outline: recursively count leaves in a tuple/list treer!)r$r·r¼rmrr¾r™Úsum)r»r´rÏrÐrªr«Úcountsrýrrrr™âs   r™z)ReportLab PDF Library - www.reportlab.comc@sLeZdZdZeZdZdZdZdZ dZ dZ dd „Z d d „Z d d „Zdd„ZdS)r\zÌ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.z)ReportLab PDF Library - www.reportlab.comZuntitledZ anonymousZ unspecifiedrµNcCs d|_dS)NÚFalse)Útrapped)r9rrrrhÿszPDFInfo.__init__cCs0x*|j|j|j|jfD]}|jt|ƒƒqWdS)N)rªr¬r®r¶rKr )r9Z md5objectr'rrrrsszPDFInfo.digestcCs”i}t|jƒ|d<t|jƒ|d<t|j|jd�|d<|d<t|jƒ|d<t|jƒ|d<t|jƒ|d<t|j ƒ|d <t |j ƒ|d <t |ƒ}|j |ƒS) NrªÚAuthor)Útsr¹ZModDateZ CreationDateZProducerZCreatorZSubjectZKeywordsZTrapped)rVrªr¬ÚPDFDaterLr¸r³r°r®r¶r¤rÔr^r,)r9r3rãr¯rrrr,szPDFInfo.formatcCs0|jƒ}x"|jjƒD]\}}t|||ƒqW|S)z'shallow copy - useful in pagecatchering)Z __klass__Ú__dict__rmry)r9rormr[rrrrsz PDFInfo.copy)rrrr@r²r³r°rªr¬r®r¶r¸rhrsr,rrrrrr\ósr\c @sLeZdZdZdedƒfgZdZedZddd„Zdd„Z dd„Z dd„Z dS) Ú Annotationzsuperclass for all annotations.rhZAnnotÚRectr…ÚSubtypeÚBorderÚCÚTÚMÚFÚHÚBSÚAAÚASÚPopupr¢ÚAPr!cCs2|d}t|ƒst|ƒ|d<t|d|ƒ|d<|S)z@transform dict args from python form to pdf string rep as neededrÚr…)r rJrV)r9ÚdrrÚrrrÚcvtdict#s  zAnnotation.cvtdictcKs´d|kr|d}|d=nd}i}x|jD]\}}|||<q(W|j|ƒx"|jD]}||krNtd|ƒ‚qNW|j||d�}|j}x,|jƒD] }||krˆtd|jj|fƒ‚qˆWt |ƒS)Nrr!zkeyword argument %s missing)rz$%s bad annotation dictionary name %s) rorKÚrequiredr�rèÚ permittedrlr€rr^)r9ÚkwrrçrzÚvalrêrrrÚAnnotationDict*s"   zAnnotation.AnnotationDictcCs tdƒ‚dS)NzEDictString undefined for virtual superclass Annotation, must overload)r�)r9rrrÚDict=szAnnotation.DictcCs|jƒ}|j|ƒS)N)rîr,)r9r3rãrrrr,AszAnnotation.formatN)rhrÚr…rÛ) rÜrÝrÞrßràrárârãrärår¢ræ)r!) rrrr@r¤rorérêrèrírîr,rrrrrÙs rÙc@s&eZdZejdZdd„Zdd„ZdS)ÚFreeTextAnnotationÚDAcKs||_||_||_||_dS)N)rÚr…rðÚotherkw)r9rÚr…rðrërrrrhGszFreeTextAnnotation.__init__cCsBi}|j|jƒ|j|d<|j|d<|j|d<d|d<|jf|ŽS)NrÚr…rðz /FreeTextrÛ)rKrñrÚr…rðrí)r9rçrrrrîLs    zFreeTextAnnotation.DictN)rð)rrrrÙrêrhrîrrrrrïEs rïc@s0eZdZejd Zd dd„Zdd„Zd d „Zd S)ÚLinkAnnotationr«rŸÚPAú[0 0 1]cKs"||_||_||_||_||_dS)N)rÜrÚr…Ú Destinationrñ)r9rÚr…rõrÜrërrrrhYs zLinkAnnotation.__init__cCsdS)Nz„ << /Type /Annot /Subtype /Link /Rect [71 717 190 734] /Border [16 16 1] /Dest [23 0 R /Fit] >> r)r9rrrÚdummyDictString`szLinkAnnotation.dummyDictStringcCsLi}|j|jƒ|j|d<|j|d<|j|d<d|d<|j|d<|jf|ŽS)NrÜrÚr…z/LinkrÛr«)rKrñrÜrÚr…rõrí)r9rçrrrrîfs     zLinkAnnotation.DictN)r«rŸró)rô)rrrrÙrêrhrörîrrrrròUs  ròc@s>eZdZdZejdZdddgfdd„Zdd d „Zd d „Zd S)Ú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. Ú QuadPointsg�Âõ(\�ê?g{®Gázì?gffffffî?cKs"||_||_||_||_||_dS)N)rÚr…rñrøÚColor)r9rÚr…rørùrërrrrh{s zHighlightAnnotation.__init__r!cCsŽ|d}|d}|d}t|tƒs8t|ƒj|dd�|d<t|tƒsXt|ƒj|dd�|d<t|tƒsxt|ƒj|dd�|d<t|d|ƒ|d<|S)z@transform dict args from python form to pdf string rep as neededrÚrørÝr$)r.r…)r$r%rJr,rV)r9rçrrÚZQuadrùrrrrè‚s   zHighlightAnnotation.cvtdictcCsLi}|j|jƒ|j|d<|j|d<d|d<|j|d<|j|d<|jf|ŽS)NrÚr…z /HighlightrÛrørÝ)rKrñrÚr…rørùrí)r9rçrrrrî�s     zHighlightAnnotation.DictN)rø)r!) rrrr@rÙrêrhrèrîrrrrr÷ps   r÷c@s&eZdZejdZdd„Zdd„ZdS) ÚTextAnnotationÚOpenÚNamecKs8tj|||f|jddƒpt|ƒ|jddƒdœ|—ŽdS)Nrørùr)rørù)rrr)r÷rhr/Ú rect_to_quad)r9rÚr…rërrrrh�s zTextAnnotation.__init__cCstj|ƒ}d|d<|S)Nz/TextrÛ)r÷rî)r9rçrrrrî¤s zTextAnnotation.DictN)rûrü)rrrr÷rêrhrîrrrrrúšsrúc Cs4|d|d|d|d|d|d|d|dgS)z9 Utility method to convert a Rect to a QuadPoint rr!rr"r)rÚrrrrý©srýc@seZdZdd„Zdd„ZdS)Ú PDFRectanglecCs ||||f\|_|_|_|_dS)N)ÚllxÚllyÚulxÚury)r9rÿrZurxrrrrrh¶szPDFRectangle.__init__cCs"t|j|j|j|jgƒ}t||ƒS)N)rJrÿrrrr,)r9r3rŸrrrr,¸szPDFRectangle.formatN)rrrrhr,rrrrrþµsrþc@s&eZdZddd„Zdd„Zdd„ZdS) r×NcCs"|dkrtƒ}|j|ƒ||_dS)N)rÚ_initr¹)r9rÖr¹rrrrh¾s zPDFDate.__init__cCs|j|_|j|_|j|_dS)N)ZYMDhmsÚdateÚdhhÚdmm)r9rÖrrrrÄsz PDFDate._initcs&ˆjp‡fdd„}tt|ˆjŽƒ|ƒS)Nc sd||||||ˆjˆjfS)Nz%D:%04d%02d%02d%02d%02d%02d%+03d'%02d')rr)ZyyyyÚmmÚddZhhÚmrø)r9rrÚËsz PDFDate.format..)r¹r,rVr)r9ruZdfmtr)r9rr,És zPDFDate.format)NN)rrrrhrr,rrrrr×¼s r×c@steZdZdZdZZZdd„Zdd„Zdd„Zd d „Z d d „Z d d„Z dd„Z dd„Z dd„Zdd„Zdd„ZdS)rõaM 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). NcCs||_d|_|_dS)N)rzÚfmtr�)r9rzrrrrhâszDestination.__init__cCsH|j}|dkrtd|jƒ‚|j}|dkr8td|jƒ‚||_|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')r r�rzr�r,)r9r3r5Úprrrr,åszDestination.formatcCstd|||ƒ|_dS)N)ÚPDFDestinationXYZr )r9ÚleftÚtopÚzoomrrrÚxyzìszDestination.xyzcCstdƒ|_dS)N)ÚPDFDestinationFitr )r9rrrÚfitîszDestination.fitcCstdƒ|_dS)N)ÚPDFDestinationFitBr )r9rrrÚfitbðszDestination.fitbcCstd|ƒ|_dS)N)ÚPDFDestinationFitHr )r9rrrrÚfithòszDestination.fithcCstd|ƒ|_dS)N)ÚPDFDestinationFitVr )r9rrrrÚfitvôszDestination.fitvcCstd|ƒ|_dS)N)ÚPDFDestinationFitBHr )r9rrrrÚfitbhöszDestination.fitbhcCstd|ƒ|_dS)N)ÚPDFDestinationFitBVr )r9rrrrÚfitbvøszDestination.fitbvcCstd||||ƒ|_dS)N)ÚPDFDestinationFitRr )r9rÚbottomÚrightrrrrÚfitrúszDestination.fitrcCs ||_dS)N)r�)r9r�rrrÚsetPageüszDestination.setPage)rrrr@Zrepresentationr,r�rhrrrrrrrr!r"rrrrrõÐs rõc@s eZdZdZdd„Zdd„ZdS)r ZXYZcCs||_||_||_||_dS)N)r�rrr)r9r�rrrrrrrhszPDFDestinationXYZ.__init__cCs4|j|jƒ}t|t|jƒ|j|j|jgƒ}t||ƒS)N) r+r�rJr¤Útypenamerrrr,)r9r3ÚpagerefrŸrrrr,s zPDFDestinationXYZ.formatN)rrrr#rhr,rrrrr sr c@s eZdZdZdd„Zdd„ZdS)rZFitcCs ||_dS)N)r�)r9r�rrrrhszPDFDestinationFit.__init__cCs(|j|jƒ}t|t|jƒgƒ}t||ƒS)N)r+r�rJr¤r#r,)r9r3r$rŸrrrr,s zPDFDestinationFit.formatN)rrrr#rhr,rrrrr src@seZdZdZdS)rZFitBN)rrrr#rrrrrsrc@s eZdZdZdd„Zdd„ZdS)rZFitHcCs||_||_dS)N)r�r)r9r�rrrrrhszPDFDestinationFitH.__init__cCs,|j|jƒ}t|t|jƒ|jgƒ}t||ƒS)N)r+r�rJr¤r#rr,)r9r3r$rŸrrrr,s zPDFDestinationFitH.formatN)rrrr#rhr,rrrrrsrc@seZdZdZdS)rZFitBHN)rrrr#rrrrr!src@s eZdZdZdd„Zdd„ZdS)rZFitVcCs||_||_dS)N)r�r)r9r�rrrrrh&szPDFDestinationFitV.__init__cCs,|j|jƒ}t|t|jƒ|jgƒ}t||ƒS)N)r+r�rJr¤r#rr,)r9r3r$rŸrrrr,(s zPDFDestinationFitV.formatN)rrrr#rhr,rrrrr$src@seZdZdZdS)rZFitBVN)rrrr#rrrrr-src@s eZdZdZdd„Zdd„ZdS)rZFitRcCs"||_||_||_||_||_dS)N)r�rrr r)r9r�rrr rrrrrh2s zPDFDestinationFitR.__init__cCs8|j|jƒ}t|t|jƒ|j|j|j|jgƒ}t ||ƒS)N) r+r�rJr¤r#rrr rr,)r9r3r$rŸrrrr,4s "zPDFDestinationFitR.formatN)rrrr#rhr,rrrrr0src@s^eZdZdZdd„Zdd„djƒDƒZdZdd„Zdd„Z dd„Z dd„Z dd„Z dd„Z dS)r‡z7each element *could* be reset to a reference if desiredcKsDx"|jD]}t|||j|iƒƒqW|jƒd|kr@|jdƒ|_dS)NÚProcSet)Údict_attributesryr/r‹r%)r9ÚkwdsÚ_rrrrh?s  zPDFResourceDictionary.__init__cCsg|] }t|ƒ‘qSr)r¤)r%rørrrr&Fsz PDFResourceDictionary.zPDF Text ImageB ImageC ImageIÚ ColorSpacer�rŽÚFontÚPatternÚ PropertiesÚShadingcCs |j|_dS)N)Ústdprocsr%)r9rrrrŠIszPDFResourceDictionary.allProcscCs|jdd…|_dS)Nr)r.r%)r9rrrr‹Msz PDFResourceDictionary.basicProcscCsttƒ|_dS)N)r˜rr*)r9rrrrˆPsz PDFResourceDictionary.basicFontscCs(x"|jƒD]\}}t|ƒ|j|<q WdS)N)rmr˜r))r9Z colorsUsedrùrørrrr�Ssz#PDFResourceDictionary.setColorSpacecCs(x"|jƒD]\}}t|ƒ|j|<q WdS)N)rmr˜r-)r9Z shadingUsedrùrørrrr�Wsz PDFResourceDictionary.setShadingcCsˆi}x@|jD]6}t||ƒ}t|tƒr:|rBt|ƒ}|||<q |||<q W|j}d}t|ƒrn|rvt|ƒ}|||<n|||<t|ƒ}t||ƒS)Nr%) r&r~r$rßr^r%rrJr,)r9r3rãZdnamer[Zdvrgrrrr,[s"      zPDFResourceDictionary.formatN)r)r�rŽr*r+r,r-)rrrr@rhr9r.r&rŠr‹rˆr�r�r,rrrrr‡=sr‡c@s4eZdZdZdZdjƒZdZdZdjƒZ dd„Z d S) Ú PDFType1Fontz"no init: set attributes explicitlyr!zType Subtype BaseFont Namer*ZType1z;FirstChar LastChar Widths Encoding ToUnicode FontDescriptorcCsri}x.|jD]$}t||ƒr t||ƒ}t|ƒ||<q Wx*|jD] }t||ƒr Újpeg_fhrú.jpgú.jpeg)rC)rCrD)rzÚwidthÚheightÚbitsPerComponentÚ colorSpacerrOÚ_filtersÚ streamContentÚmaskr*ÚloadImageFromSRCr‡ÚpathÚsplitextÚlowerrÚloadImageFromJPEGÚloadImageFromA85ÚloadImageFromRawr†)r9rzÚsourcerKr‡ÚextÚsrcrrrrhs*   zPDFImageXObject.__init__cCs¼g}tj||dd�}|s&|j|dƒSdd„|Dƒ}|djƒ}t|dƒt|dƒ|_|_dd d d œ|d |_d |_d|_ |r”|j |dƒn|j dkr¤d|_ dj |dd…ƒ|_ dS)NT)ÚIMGÚ detectJpegrcSsg|] }|jƒ‘qSr)rN)r%rørrrr&.sz4PDFImageXObject.loadImageFromA85..r!r"r<r=r>)z/RGBz/Gz/CMYKéérCr;rÿrµ)rCr;rµ)rZ makeA85ImagerLr9r1rErFrHrGrIÚ_checkTransparencyrKrrJ)r9rSrVÚ imagedataÚwordsrrrrQ)s  z PDFImageXObject.loadImageFromA85cCs°y ztj|ƒ}Wd|jdƒXWn dS|d|d|_|_d|_|ddkr\d|_n |ddkrpd|_n d |_d|_|jƒ|_ t j r t |j ƒ|_ d |_ nd|_ d|_d S)NrFr!rYrr=r"r<r>rCÚ DCTDecodeT)rCr])r])rZ readJPEGInfoÚseekrErFrGrHÚ_dotransÚreadrJrrOrrIrK)r9Z imageFiler>rrrrP8s*    z!PDFImageXObject.loadImageFromJPEGcCs¬g}tj||dd�}|s&|j|dƒS|djƒ}t|dƒ|_t|dƒ|_dddd œ|d |_d |_d|_ |r„|j |dƒn|j d kr”d|_ dj |dd…ƒ|_ dS)NT)rVrWrr!r"r<r=r>)z/RGBz/Gz/CMYKrXrYr;rÿrY)r;rµ)rZ makeRawImagerLr9r1rErFrHrGrIrZrKrrJ)r9rSrVr[r\rrrrRRs  z PDFImageXObject.loadImageFromRawcCsÄ|jdkr€|jr@d|_tt|jjƒƒ|jdd�|_ddg|j_qÀ|jƒ}|rx|d|d|d|d|d|df|_qÀd|_n@t|jdƒrÀ|jj ƒ}|d|d|d|d|d|df|_dS)Nrÿ)rKrr!rÚrgb) rKZ_dataAr?r Ú getRGBDataZ_smaskÚ_decodeZgetTransparentr*ra)r9ÚimZtcr(rrrrZas ,  z"PDFImageXObject._checkTransparencycCs||jƒ}|r|j|ƒn`|jƒ\|_|_|jƒ}tj|ƒ|_t j rVt |jƒ|_d|_ nd|_ t |j|_d|_|j|ƒdS)z%Extracts the stream, width and heightrCr;rYN)rCr;)r;)rBrPZgetSizerErFrbr<r=rJrrOrrIÚ_mode2CSrtrHrGrZ)r9rdÚfprqrrrrLqs    z PDFImageXObject.loadImageFromSRCc Csút|jd�}|j}tdƒ|d<tdƒ|d<|j|d<|j|d<|j|d<t|jƒ|d <|jd krŠt|d d ƒrŠt d d d d d d d d gƒ|d<nt|ddƒr¤t |j ƒ|d<t t t|j ƒƒ|d<t |jƒ|d<|jrÚt |jƒ|d<t|ddƒrð|j|d<|j|ƒS)N)rEr�rhZImagerÛZWidthZHeightZBitsPerComponentr)r>r_rr!ZDecodercrGrHZMaskÚsmaskZSMask)rÝrJrÞr¤rErFrGrHr~rJrcr3rIrÊrKrgr,)r9r3rRrßrrrr,„s&        zPDFImageXObject.format)NN) rrrrhrQrPrRrZrLr,rrrrr?s !r?c@s$eZdZdd„Zdd„Zdd„ZdS)r¥cCsHddlm}t||ƒs(td|jjƒ‚n|js>td|jjƒ‚||_dS)Nr)Ú CMYKColorz%s needs a CMYKColor argumentz-%s needs a CMYKColor argument with a spotName)Zreportlab.lib.colorsrhr$r�r€rr¢r§)r9r§rhrrrrh˜s   zPDFSeparationCMYKColor.__init__cCs¨gj}x�t|jjƒƒD]~\}}t|ƒ}|dkr^|dkrH|dƒ|dƒq”|t|ƒƒ|dƒq|dkrp|dƒn|dƒ|t|ƒƒ|dƒ|dƒqWd d j|jƒS) zpcreate the postscript code for the tint transfer function effectively this is tint*c, tint*y, ... tint*kr"gr/z0.0ÚmulrÚdupZexchz{%s}ú )r¾rr§r0r%rÚ__self__)r9rærr[rrrÚ _makeFuncPS s       z"PDFSeparationCMYKColor._makeFuncPScCsDttdƒt|jjƒtdƒtttdtdƒtd ƒd�ƒ|jƒdd�fƒS) NZ Separationr>r#rr!)Ú FunctionTypeÚDomainÚRange)rÞrErF)rr!)rr!rr!rr!rr!)rWr¤r§r¢rÝr^rßrm)r9rrrr¦·s  zPDFSeparationCMYKColor.valueN)rrrrhrmr¦rrrrr¥—sr¥c@s8eZdZdZgZd Zed Zdd„Zdd„Zd d „Z d S)Ú PDFFunctionz"superclass for all function types.rnrorpcKs‚i}x|jD]\}}|||<q W|j|ƒx"|jD]}||kr2td|ƒ‚q2W|j}x$|jƒD]}||kr^td|ƒ‚q^Wt|ƒS)Nzkeyword argument %s missingz!bad annotation dictionary name %s)rorKrér�rêrlr^)r9rërçrzrìrêrrrÚ FunctionDictÌs   zPDFFunction.FunctionDictcCs tdƒ‚dS)Nz?Dict undefined for virtual superclass PDFShading, must overload)r�)r9r3rrrrîÚszPDFFunction.DictcCs|j|ƒ}|j|ƒS)N)rîr,)r9r3rãrrrr,ßs zPDFFunction.formatN)rnro)rp) rrrr@rorérêrrrîr,rrrrrqÇsrqc@sDeZdZejded ƒfgZejd ZejdZdd„Zd d „Z d S)ÚPDFExponentialFunctionroççð?ÚNÚC0ÚC1cKs||_||_||_||_dS)N)rwrxrvrñ)r9rwrxrvrërrrrhçszPDFExponentialFunction.__init__cCsJi}|j|jƒd|d<t|jƒ|d<t|jƒ|d<|j|d<|jf|ŽS)Nrrnrwrxrv)rKrñrWrwrxrvrr)r9r3rçrrrrîìs  zPDFExponentialFunction.DictN)rtru)rv)rwrxrv) rrrrqrorWrérêrhrîrrrrrsãs   rsc@s0eZdZejd Zejd Zdd„Zdd„ZdS) ÚPDFStitchingFunctionÚ FunctionsÚBoundsÚEncodecKs||_||_||_||_dS)N)rzr{r|rñ)r9rzr{r|rërrrrhøszPDFStitchingFunction.__init__cs\i}|j|jƒd|d<t‡fdd„|jDƒƒ|d<t|jƒ|d<t|jƒ|d<|jf|ŽS)Nr"rncsg|]}ˆj|ƒ‘qSr)r+)r%r')r3rrr& sz-PDFStitchingFunction.Dict..rzr{r|)rKrñrJrzr{r|rr)r9r3rçr)r3rrîýs zPDFStitchingFunction.DictN)rzr{r|)rzr{r|)rrrrqrérêrhrîrrrrryõs  ryc@s4eZdZdZdZedZdd„Zd d „Zd d „Zd S)Ú PDFShadingz!superclass for all shading types.Ú ShadingTyper)Ú Backgroundr8Ú AntiAliascKsfi}|j|ƒx"|jD]}||krtd|ƒ‚qW|j}x$|jƒD]}||krBtd|ƒ‚qBWt|ƒS)Nzkeyword argument %s missingz!bad annotation dictionary name %s)rKrér�rêrlr^)r9rërçrzrêrrrÚ ShadingDict s  zPDFShading.ShadingDictcCs tdƒ‚dS)Nz?Dict undefined for virtual superclass PDFShading, must overload)r�)r9r3rrrrî szPDFShading.DictcCs|j|ƒ}|j|ƒS)N)rîr,)r9r3rãrrrr, s zPDFShading.formatN)r~r))rr8r€) rrrr@rérêr�rîr,rrrrr} s  r}c@s0eZdZejd Zejd Zdd„Zdd„ZdS) ÚPDFFunctionShadingÚFunctionror9cKs||_||_||_dS)N)rƒr)rñ)r9rƒr)rërrrrh" szPDFFunctionShading.__init__cCsBi}|j|jƒd|d<t|jƒ|d<|j|jƒ|d<|jf|ŽS)Nr!r~r)rƒ)rKrñr¤r)r+rƒr�)r9r3rçrrrrî& s  zPDFFunctionShading.DictN)rƒ)ror9rƒ)rrrr}rérêrhrîrrrrr‚ s  r‚c@s0eZdZejd Zejd Zdd„Zdd„Zd S) ÚPDFAxialShadingÚCoordsrƒroÚExtendcKs$||||f|_||_||_||_dS)N)r…rƒr)rñ)r9Úx0Úy0Úx1Úy1rƒr)rërrrrh2 szPDFAxialShading.__init__cCsPi}|j|jƒd|d<t|jƒ|d<t|jƒ|d<|j|jƒ|d<|jf|ŽS)Nrr~r)r…rƒ) rKrñr¤r)rWr…r+rƒr�)r9r3rçrrrrî7 s zPDFAxialShading.DictN)r…rƒ)r…rorƒr†)rrrr}rérêrhrîrrrrr„. s  r„c@s0eZdZejd Zejd Zdd„Zdd„Zd S) ÚPDFRadialShadingr…rƒror†c Ks(||||||f|_||_||_| |_dS)N)r…rƒr)rñ) r9r‡rˆÚr0r‰rŠÚr1rƒr)rërrrrhD szPDFRadialShading.__init__cCsPi}|j|jƒd|d<t|jƒ|d<t|jƒ|d<|j|jƒ|d<|jf|ŽS)Nr"r~r)r…rƒ) rKrñr¤r)rWr…r+rƒr�)r9r3rçrrrrîI s zPDFRadialShading.DictN)r…rƒ)r…rorƒr†)rrrr}rérêrhrîrrrrr‹@ s  r‹Ú__main__z-There is no script interpretation for pdfdoc.)r!r")r!r#)r)N)N)ƒÚ __version__r@rïr r<Ú collectionsrr½rÚ reportlabrrˆrrrrr r r r r rZreportlab.lib.rl_accelrrrrrÚhashlibrÚsysrÚ Exceptionrrrrrr rérßrkr(r,r7ZformNamer8r)r?rBZPDFtrueZPDFfalseZPDFnullrtrôÚreÚcompilerörúrþrVÚchrr¤r^r2r5r6r8r:rQrBrPrÝrSrMrJrWrÈr˜rÇr^rËrÍrRrUrxr“r”r�r§r¨rXr©rYr™r²r\rÙrïròr÷rúrýrþr×rõr rrrrrrrr‡r/r2rÛr;rer?r¥rqrsryr}r‚r„r‹rr‰rrrrÚsà    0    &  I -   *  %4W(KA *(* 0     9#@ 0