)Ej7hdZddlZddlZddlmZmZddlmZmZddl m Z ddl m Z m Z ddl mZddlmZdd lmZd d lmZmZd d lmZmZd d lmZd dlmZmZm Z m!Z!d dl"m#Z#d dl$m%Z%d dl&m'Z'm(Z(m)Z)d dl*m+Z+d dl,m-Z-d dl.m/Z/m0Z0m1Z1d dl2m3Z3m4Z4m5Z5m6Z6d dl7m8Z8m9Z9d dl:m;Z;mZ>m?Z?m@Z@mAZAmBZBmCZCmDZEmFZGmHZId dlJmKZKmLZL ddlMmNZNn #eO$rdZNYnwxYwddlPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYeQr0d dlmZZZm[Z[d dl\m]Z]m^Z^d dlm_Z_m`Z`d dl&maZad dlbmcZcd d ldmeZed d!lfmgZgejheiZjd"d#d$d%ZkGd&d'eZlGd(d)elZmGd*d+e@ZnGd,d-e@ZoGd.d/e@ZpGd0d1e@ZqGd2d3ZrGd4d5e@ZsGd6d7e@ZtGd8d9e>ZuGd:d;e>ZvGd<d=e>ZwGd>d?e>ZxGd@dAZyGdBdCe@ZzGdDdEe@Z{GdFdGe@Z|GdHdIelZ}GdJdKZ~eXeeefdkZdldmdjed]e>fdnZdS)qai This module contains the serialization logic that produces a PDF document from a FPDF instance. Most of the code in this module is used when FPDF.output() is called. The contents of this module are internal to fpdf2, and not part of the public API. They may change at any time without prior warning or any deprecation period, in non-backward-compatible ways. N)ABCabstractmethod) OrderedDict defaultdict)contextmanager)datetimetimezone)escape)BytesIO)subset)AnnotationDict PDFAnnotation) ImageSoftMask PaintSoftMask) Transform)OutputIntentSubTypePageLabelStylePDFResourceType SignatureFlag) FPDFException) Type3Font) CORE_FONTSCoreFontTTFFont)RasterImageInfo)TotalPagesSubstitutionFragment)OutlineDictionaryOutlineItemDictionarybuild_outline_objs)Gradient MeshShadingPatternShading) Signature sign_content) DestinationXYZNamePDFArrayPDFContentStreamPDFDate PDFObject PDFStringRawbuild_obj_dictcreate_dictionary_stringcreate_list_stringiobj_ref) int2romanint_to_letters)signer) TYPE_CHECKINGAny ItemsViewIteratorLiteralOptionalSequenceUnioncast) BlendGroup GraphicsStyle)EncryptionDictionaryStandardSecurityHandler) PageLayoutPageMode)PDFFontDescriptor)FPDF)ViewerPreferences) Transition)z/Fit)z/FitHnull)/XYZrIrI1)fullpage fullwidthrealc>eZdZe ddeddefdZdS)ContentWithoutIDN_security_handlerrBreturnctN)NotImplementedErrorselfrQs =C:\PYTHON\MyICR_Suite\python\Lib\site-packages\fpdf/output.py serializezContentWithoutID.serialize[s "!rT)__name__ __module__ __qualname__rr;strrYrZrXrPrPYsPGK""!)*C!D" """^"""rZrPcBeZdZdZdeddfdZ d deddefdZdS) PDFHeaderu Emit the PDF file header as required by ISO 32000-1, §7.5.2 “File header”. The header consists of: 1) A line starting with the literal "%PDF-" followed by the file version 2) If the file contains binary data an immediate second line that is a comment starting with "%" and containing at least four bytes with values ≥ 128 (non-ASCII). This helps file-transfer tools treat the content as binary rather than text. pdf_versionrRNc||_dSrTrb)rWrbs rX__init__zPDFHeader.__init__ms&rZrQrBcd|jdS)Nz%PDF-u %éëñ¿rdrVs rXrYzPDFHeader.serializeps5t'4444rZrT)r[r\r]__doc__r^rer;rYr_rZrXrarabsv'C'D''''HL55!)*C!D5 555555rZrac deZdZ d dededeedeedeeddf fd ZxZS) PDFFontNsubtype base_fontencodingd_wwrRcRttd|_t||_t||_|rt|nd|_||_||_d|_ d|_ d|_ d|_ d|_ dS)NFont)superrer(typerjrkrlrmrndescendant_fonts to_unicodec_i_d_system_infofont_descriptorc_i_d_to_g_i_d_map)rWrjrkrlrmrn __class__s rXrezPDFFont.__init__ws LL G}} i*2<X 486::>>B>BrZ)NNN)r[r\r]r^r;floatre __classcell__rxs@rXririvs #'# CCCC3- C e_ C C= C CCCCCCCCCCrZric eZdZdfd ZxZS) CIDSystemInforRNcttdd|_tdd|_d|_dS)NAdobeTencryptUCSr)rqrer-registryordering supplement)rWrxs rXrezCIDSystemInfo.__init__sL !'4888 !%666 rZrRN)r[r\r]rerzr{s@rXr}r}s=rZr}ceZdZdfd ZedefdZedefdZedefdZd e e d fd e ed fd e edfddfdZ defdZ xZ S) PDFType3Fontfont3rrRNc t||_td|_td|jj|_td|_d|jjjdj |jj zdd|jjjdj |jj zdd|jjjdj |jj zdd|jjjdj |jj zdd |_d |_t!d |jD|_t'd |jD|_d|_d|_dS) NrpMPDFAA+Type3[headz.0f ]z[0.001 0 0 0.001 0 0]c3$K|] }|jV dSrTunicode.0gs rX z(PDFType3Font.__init__..s$>>Aai>>>>>>rZc3$K|] }|jV dSrTrrs rXrz(PDFType3Font.__init__..s$==1QY======rZ)rqre_font3r(rrrknamerjttfontxMinscaleyMinxMaxyMax font_b_box font_matrixminglyphs first_charmax last_char resourcesrt)rWrrxs rXrezPDFType3Font.__init__sw  LL 95?#799:: G}}  U %,V49DK>>>>>>== =====(,)-rZcHtd|jjDS)Nc4i|]}d|j|jdS)/ 0 R) glyph_nameobj_idrs rX z+PDFType3Font.char_procs..s0 O O Oq   AH!2!2!2 O O OrZ)pdf_dictrrrWs rX char_procszPDFType3Font.char_procss* O ODK&>    rZc t|jjd}|dj}|dj}dg|dz|z z}|D]1}t |j|jjzdz||j|z <2td|DS)Nc|jSrTrglyphs rXz%PDFType3Font.widths..U]rZkeyrr gMbP?c,g|]}t|Sr_r^)r glyph_widths rX z'PDFType3Font.widths..s DDDk[))DDDrZ)sortedrrrroundrrpdf_list)rW sorted_glyphs min_unicode max_unicodewidthsrs rXrzPDFType3Font.widthsst{17R7RSSS #A&. #B'/  a+56#  E27!DK$55=33F5=;. / /DDVDDDEEErZimg_objs_per_index PDFXObjectgfxstate_objs_per_name PDFExtGStatepattern_objs_per_namer#cd}dfdjjD}|t|dkrd|dndz }dfd|D}|t|dkrd |dndz }dfd |D}|t|dkrd |dndz }|dz }|_dS) N<.sS   8 7 7)#.1 7 7 7      rZrz /XObject <<>>c3VK|]#\}}|jjvd|d|jdV$dSrrrN)rgraphics_style_usedr)rr gfxstate_objrWs rXrz2PDFType3Font.generate_resources..sX  "lt{666 - , ,| , , ,6666  rZz /ExtGState <.sX  gt{000 ( ' 'wz ' ' '0000  rZz /Pattern <<)joinr images_usedlenitemsr)rWrrrrobjects ext_g_staters`` rXgenerate_resourceszPDFType3Font.generate_resourcessr  ((    {.      #g,,2B2B.7....J hh    &<&B&B&D&D     K8H8H18L8L4[4444RTT ((    !6!!>      #g,,2B2B.7....J T "rZct|jjd}ddd|DzdzS)Nc|jSrTrrs rXrz0PDFType3Font.differences_table..rrZrr c38K|]}|jd|jVdS)z /N)rr)rrs rXrz1PDFType3Font.differences_table..sF;@5=66E$466rZr)rrrr)rWrs rXrzPDFType3Font.differences_tablesat{17R7RSSS iiDQ    rZ)rrrRN)r[r\r]repropertyr^rrlrdictintrrrzr{s@rXrrs)......$ C   X  #   X FFFFXF # l!23#!%S.%8 9# $CN3 #  ####< 3        rZrceZdZdeedeedeedeedeedeededd ffd ZxZS) PDFInfotitlesubjectauthorkeywordscreatorproducer creation_daterRNct|rt|dnd|_|rt|dnd|_|rAt |t ttfrd d|D}|rt|dnd|_ |rAt |t ttfrd d|D}|rt|dnd|_ |rt|dnd|_ |rt|dnd|_ ||_dS)NTrz; c34K|]}t|VdSrTr)ras rXrz#PDFInfo.__init__..s(66!s1vv666666rZ, c34K|]}t|VdSrTr)rkeywords rXrz#PDFInfo.__init__..s( F F'W F F F F F FrZ)rqrer-rr isinstancelisttuplesetrrrrrr) rWrrrrrrrrxs rXrezPDFInfo.__init__s_ 7<FYud3333$ ;BLy$7777  7j$s);<< 7YY66v66666F9?Ii5555T  G 8dE3-?@@ Gyy F FX F F FFFH=EO (D99994 ;BLy$7777 =EO (D99994 *rZ)r[r\r]r;r^r+rerzr{s@rXrrs+}+#+ + 3- + # +3-++ ++++++++++rZrcPeZdZdedefdZ d deddeedefd ZdS) AcroFormfields sig_flagsc"||_||_dSrTrr)rWrrs rXrezAcroForm.__init__ s "rZNrQrB_obj_idrRc|tfdtD||}t|dS)Nc2i|]}|t|Sr_getattrrrrWs rXrz&AcroForm.serialize..% : : :S'$$$ : : :rZrQrr field_joinr/dirrrWrQrobj_dicts` rXrYzAcroForm.serializesQ " : : : :D : : :/    S1111rZNN) r[r\r]r)rrer;r^rYr_rZrXrr s#x#C#### BF!% 2 2#$=> 2# 2 2 2 2 2 2 2rZrc neZdZ d deededdeddedd df fd ZxZS) PDFCatalogNlang page_layoutrC page_moderDviewer_preferencesrGrRcdttd|_|rt |nd|_||_||_||_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_d|_d|_d|_dS)NCatalog)rqrer(rrr-rrrrpages acro_form open_action mark_infometadatanamesoutlinesoutput_intentsstruct_tree_roota_f page_labels)rWrrrrrxs rXrezPDFCatalog.__init__s OO '+5IdOOO &""4  .2*.(,26 $( 59 2659"&*.rZNNNNr[r\r]r;r^rerzr{s@rXrrs#.2*.<@ //sm/l+/J' / %%89 /  //////////rZrceZdZdeedeedeedeedeedeeddffd ZxZS) PDFResourcesproc_setfontx_objectrshadingrrRNct||_||_||_||_||_||_dSrT)rqrer+r,r-rr.r)rWr+r,r-rr.rrxs rXrezPDFResources.__init__:sJ      &  rZr(r{s@rXr*r*9s3-sm3-  c]  # # rZr*c(eZdZdeddffd ZxZS) PDFFontStreamcontentsrRNcvt|dt||_dSNTr2compress)rqrerlength1rWr2rxs rXrezPDFFontStream.__init__Ms1 (T:::8}} rZ)r[r\r]bytesrerzr{s@rXr1r1LsK%%4%%%%%%%%%%rZr1c(eZdZdeddffd ZxZS)PDFXmpMetadatar2rRNct|dtd|_td|_dS)Nzutf-8r2MetadataXML)rqreencoder(rrrjr8s rXrezPDFXmpMetadata.__init__SsJ (//'":":;;;$$ E{{ rZ)r[r\r]r^rerzr{s@rXr;r;RsK############rZr;ceZdZdZ ddededededeezdzd e d e ed e ed e ed e ddffd Z xZ S)r)_id _contentsfilterlengthrrrjwidthheight color_spacebits_per_componentdecode decode_parmss_mask image_maskNFr2rjrFrGrHrI img_filterrJrKrMrRc <t|td|_t||_||_||_||_||_t||_ ||_ | |_ d|_ | rdnd|_ dS)Nr=XObjectT)rqrer(rrrjrFrGrHrIrDrJrKrLrM) rWr2rjrFrGrHrIrNrJrKrMrxs rXrezPDFXObject.__init__ks (+++OO G}}   &"4:&&  (,0 ",6$$$rZ)NNNF)r[r\r] __slots__r9r^ryr)r(rr;boolrerzr{s@rXrrYsI2%) $&* 7777 7  7 _t+ 7 7SM7 7sm77 7777777777rZrc4eZdZdZdZdededeffd ZxZ S) PDFICCProfilez Holds values for ICC Profile Stream Args: contents (str): stream content n (int): [1|3|4], # the numbers for colors 1=Gray, 3=RGB, 4=CMYK alternate (str): ['DeviceGray'|'DeviceRGB'|'DeviceCMYK'] )rBrCrDrEn alternater2rUrVct|d||_t||_dSr4)rqrerUr(rV)rWr2rUrVrxs rXrezPDFICCProfile.__init__s: (T:::irZ) r[r\r]rgrQr9rr^rerzr{s@rXrTrTsjI)) ) ))))))))))rZrTceZdZdZdZdeedeedeeddfdZ e dee fd Z e dee fd Zdefd Zdefd Zdeeeffd ZdeefdZdefdZdefdZdS) PDFPageLabelzG This will be displayed by some PDF readers to identify pages. _style_prefixst label_style label_prefix label_startrRNc0||_||_||_dSrTrZ)rWr^r_r`s rXrezPDFPageLabel.__init__s 1< &2 !,rZcF|jrt|jjndSrT)r[r(valuers rXszPDFPageLabel.ss!*.+?tDK%&&&4?rZc<|jrt|jndSrT)r\r-rs rXpzPDFPageLabel.ps*.,@y&&&D@rZc8d|jd|jd|jdS)Nz PDFPageLabel(r)rZrs rX__repr__zPDFPageLabel.__repr__s)Ht{HHdlHHdgHHHHrZcb|jr|jnd}|jr|jtjkr|t |jz }n|jtjkr|t|jpdz }n|jtjkr,|t|jpd z }ny|jtj kr|jpddz }|t|z }nE|jtj kr0|jpddz }|t| z }|S)Nrr ) r\r[rNUMBERr^r] UPPER_ROMANr3 LOWER_ROMANlower UPPER_LETTERr4 LOWER_LETTER)rWretstarts rX__str__zPDFPageLabel.__str__s"l2dll ; 5{n333s47||# :::yA... :::yA..44666 ;;;A*~e,,, ;;;A*~e,,22444 rZcTtfdtDS)Nc2i|]}|t|Sr_rr s rXrz*PDFPageLabel.serialize..s%LLL3sGD#$6$6LLLrZ)r/rrs`rXrYzPDFPageLabel.serializes,LLLL#d))LLLMMMrZc|jSrT)r[rs rX get_stylezPDFPageLabel.get_style {rZc|jpdS)Nr)r\rs rX get_prefixzPDFPageLabel.get_prefixs|!r!rZc|jpdSNr )r]rs rX get_startzPDFPageLabel.get_startsw|!rZ)r[r\r]rgrQr;rr^rrerr(rdr-rfrirsrr7rYrwrzr}r_rZrXrYrYs,I-n--sm-c] -  ----@8D>@@@X@A8I&AAAXAI#IIII"N4S>NNNN8N3"C""""3rZrYc,eZdZdZdeededdeezdeffd Z defd Z d edd fd Z de eeffd Z dededd fdZdeedeedd fdZdeefdZdefdZdeefdZdedd fdZdeezdd fdZxZS)PDFPage)rBrrr2durtransannotsgroup media_boxstruct_parentsrparent_index _width_pt _height_pt _page_label_text_substitution_fragmentsduration transitionrHr2indexcTttd|_||_|r|nd|_||_t|_d|_ d|_ d|_ d|_ d|_ ||_d|_d|_d|_g|_dS)NPage)rqrer(rrr2rrr)rrrrrrrrrrr)rWrrr2rrxs rXrezPDFPage.__init__s LL   '188T *2** $( (,-1     *.+/37RT)))rZrRc|jSrTrrs rXrz PDFPage.indexrxrZiNc||_dSrTr)rWrs rX set_indexzPDFPage.set_indexs  rZcX|j|jtd|j|jfS)zGReturn a pair (width, height) in the unit specified to FPDF constructorNzPage dimensions are null)rr ValueErrorrs rX dimensionszPDFPage.dimensionss/ > !T_%<788 8~t..rZwidth_pt height_ptc$||c|_|_dS)zHAccepts a pair (width, height) in the unit specified to FPDF constructorN)rr)rWrrs rXset_dimensionszPDFPage.set_dimensionss*2I'rZprevious_page_label page_labelc|ry|rw||krM||kr#|js|dz|_|r|j |jdkrd|_|rL|sJt |||dz}||_dS)Nr r)rwrzr]r}rYr)rWrrs rXset_page_labelzPDFPage.set_page_labels  @ @$$&&*=*G*G*I*III%%''+>+I+I+K+KKKML099;;a?JM  "}$ (:(: !  z %#--//#..00#--//!3J &rZc|jSrT)rrs rXget_page_labelzPDFPage.get_page_label9s rZcz|js!t|nt|jSrT)rr^rrs rX get_labelzPDFPage.get_label<s0(,(8Ss4::<<   c$BR>S>SSrZc|jSrT)rrs rXget_text_substitutionszPDFPage.get_text_substitutions?s 00rZfragmentc:|j|dSrT)rappend)rWrs rXadd_text_substitutionzPDFPage.add_text_substitutionBs )00:::::rZ annotationcn|jt|_|j|dSrT)rr)r)rWrs rXadd_annotationzPDFPage.add_annotationEs1 ; "**DK :&&&&&rZ)r[r\r]rQr;ry bytearrayr*rrerrrrrrYrrr^rr<rrrrrrrzr{s@rXrrsI&U5/U\*U.. U  UUUUUU:s34/E%,///// >u>>4>>>>&%l3&\*&  &&&&6  6    T3TTTT11O(P1111;.L;QU;;;;'-)G'D''''''''rZrc,eZdZdededdffd ZxZS) PDFPagesRootcountrrRNcttd|_||_||_d|_dS)NPages)rqrer(rrrrkids)rWrrrxs rXrezPDFPagesRoot.__init__LsB MM  "  rZ)r[r\r]rr^rerzr{s@rXrrKsR c c d          rZrcjeZdZdeddffd Z d deeeefdeddefdZxZ S) r dict_as_strrRNcVt||_dSrT)rqre _dict_as_str)rWrrxs rXrezPDFExtGState.__init__Ws' 'rZrrQrBc&|jd|jdS)Nz 0 obj z endobj)rr)rWrrQs rXrYzPDFExtGState.serialize\s '>>4#4>>>>rZr) r[r\r]r^rer;rr7rYrzr{s@rXrrVs(C(D((((((.2AE??4S>*?$$=>? ????????rZrc:eZdZdZd dZ d deddefd ZdS) PDFXrefAndTrailerz$Cross-reference table & file traileroutput_builderOutputProducerrRNc\||_|jdz|_d|_d|_d|_dSr|)rrr catalog_objinfo_objencryption_obj)rWrs rXrezPDFXrefAndTrailer.__init__gs6,#*Q. 15+/ @DrZrQrBc|jtd|j}tt |j}g}|d|d|j|dtd|jD]&}||j |dd'|d|d |d |j|d t|jj |j r/|d t|j j |j }|jrE|d t|jj |jJ|jj}n4|}|dkr||j}||d|d|d|d|||dd|S)Nz"Invalid state for XREF production.xrefz0 z0000000000 65535 f r 010z 00000 n trailerrz/Size z/Root z/Info z /Encrypt rz/ID [rr startxrefz%%EOFr)rrrr^rbufferrrrangeoffsetspdf_refrrfpdfrrQfile_id_default_file_idr)rWrQbuilderroutrrrs rXrYzPDFXrefAndTrailer.serializeosb   # DEE E%GN++,,  6 $ $$%%% ()))Atz** B BF JJ'/&1@@@@ A A A A 9 4 (DJ(())) :GD$4$788::;;; = = JJ; (8 9 9;; < < <|   @ JJD74+>+A#B#BDD E E E)555373I3QGGllnnG"}}//??   JJ)w))) * * * 4 ; 9 7yy~~rZ)rrrRNrT)r[r\r]rgrer;r^rYr_rZrXrrdsh**EEEEHL""!)*C!D" """"""rZrceZdZdZdZ ddddeedeedeed eed eed dfd Z dd eddee d efdZ dS)OutputIntentDictionarya The optional OutputIntents (PDF 1.4) entry in the document catalog dictionary holds an array of output intent dictionaries, each describing the colour reproduction characteristics of a possible output device. Args: subtype (OutputIntentSubType, required): PDFA, PDFX or ISOPDF output_condition_identifier (str, required): see the Name in https://www.color.org/registry.xalter output_condition (str, optional): see the Definition in https://www.color.org/registry.xalter registry_name (str, optional): "https://www.color.org" dest_output_profile (PDFICCProfile, required/optional): PDFICCProfile | None # (required if output_condition_identifier does not specify a standard production condition; optional otherwise) info (str, required/optional see dest_output_profile): human readable description of profile )rrrdoutput_condition_identifieroutput_condition registry_namedest_output_profileinfoNrjzOutputIntentSubType | strrrrrrrRctd|_ttj|j|_|rt |nd|_|rt |nd|_|rt |nd|_ |rt|tr|nd|_ |rt |nd|_ dS)N OutputIntent)r(rrrcoercercrdr-rrrrrTrr)rWrjrrrrrs rXrezOutputIntentDictionary.__init__s(( )099?@@+ I1 2 2 2 ( ,< EI& ' ' ' :GPY}555D# '12E}'U'U     (,5IdOOO rZrQrBrcxtfdtD||}t|S)Nc2i|]}|t|Sr_rr s rXrz4OutputIntentDictionary.serialize..r rZr rrs` rXrYz OutputIntentDictionary.serializesL " : : : :D : : :/    !!!rZr'r) r[r\r]rgrQr;r^rTrerrYr_rZrXrrs*I+/'+7;"66,6&.c]6#3- 6  } 6 &m4 6sm6 6666:BF!% " "#$=> "# " " " " " " "rZrr!r#r$r"c eZdZdZejdZejdZejdZejdZ ejdZ d!d Z d e d e d eedeefd ZdddeefdZdeezdefdZdddefdZdedeee effdZded eddfdZd e dee effdZd ed e dee fdZd e dee fdZe d e defdZ! d"dedede"e#zfd Z$dS)#ResourceCatalogzKManage the indexing of resources and association to the pages they are usedz /(GS\d+) gsz /I(\d+) Doz /(P\d+)\s+scnz /(P\d+)\s+SCNz!/F(\d+)\s+[-+]?\d+(?:\.\d+)?\s+TfrRNctt|_tt|_t |_g|_g|_d|_ i|_ d|_ dS)Nrr ) rrrrresources_per_pagergraphics_stylessoft_mask_xobjects form_xobjectslast_reserved_object_id font_registrynext_xobject_indexrs rXrezResourceCatalog.__init__siJU K K     1< :<AC,-$<>'(rZ resource_typeresource page_numberc|tjtjfvr~|j|}||}||vr|t |dz||<|(|j||f||t||S|tj kr*t|tr||j kr |dz|_ tr|J|j||f|dSr|)rPATTERNSHADINGr _get_prefixrraddr^X_OBJECTrrrr6)rWrrrrprefixs rXrzResourceCatalog.adds" _4o6MN N N~m4H%%m44Fx''(.%CH 0A%C%C"&'m(DEIIX&x)** * _5 5 58S)) 6D333&.lD #  +*** m <=AA(KKKtrZstyler@c|}|dSt|}||jvrLt|t jt|j}||j|<|j|S)z Graphics style can be added without associating to a page number right away, like when rendering a svg image. The method that adds image to the page will call the add method for the page association. N)rYr^rr(rr EXT_G_STATEr)rWr style_dict style_strrs rXregister_graphics_stylez'ResourceCatalog.register_graphics_styles %*OO$5$5  4 OO D0 0 0##O$?@@]#dFZB[B[]]D/3D  +#I..rZ soft_maskc|xjdz c_t||}|j|_|j||jS)z5Register a soft mask xobject and return its object idr )rsoft_mask_path_to_xobjectrrr)rWrxobjects rXregister_soft_maskz"ResourceCatalog.register_soft_mask'sN $$)$$+It<<1  &&w///zrZ blend_groupr?ct||}|j}|xjdz c_|j||f|S)zBRegister a blend group Form XObject and return its resource index.r )blend_group_to_xobjectrrr)rWrrrs rXregister_blend_formz#ResourceCatalog.register_blend_form/sN(d;;' 1$ !!5'"2333 rZrenderedcLt}|j|D]6}|tj|df7|j|D]6}|tj|df7|j |D]6}|tj |df7|j |D]6}|tj |df7|j |D]6}|tj |df7|S)z6Parse a content stream and return discovered resourcesr )rGS_REGEXfinditerrrrr IMG_REGEXrPATTERN_FILL_REGEXrPATTERN_STROKE_REGEX FONT_REGEXFONT)rWrfoundms rX scan_streamzResourceCatalog.scan_stream7sr25%%''11 A AA II2AGGAJJ? @ @ @ @((22 > >A II/< = = = =(11(;; = =A II. ; < < < <*33H== = =A II. ; < < < <))(33 : :A II+QWWQZZ8 9 9 9 9 rZc||D]Y\}}|tjkr-|j|tjf|B||||ZdS)z Scan a rendered content stream and register resources used on the given page. Currently indexes: - ExtGState invocations: '/GSn gs' - Image XObjects: '/In Do' N)r rrrr)rWrrrrs rXindex_stream_resourcesz&ResourceCatalog.index_stream_resourcesLs(,'7'7'A'A ? ? #M8 777'o6M(NOSS+>>>>  ? ?rZc@|j|SrT)rr)rWrs rX get_itemszResourceCatalog.get_items[s~m,22444rZc |j||fSrT)r)rWrrs rXget_resources_per_pagez&ResourceCatalog.get_resources_per_page`s& ]'CDDrZct}|jD]#\\}}}||kr||$|SrT)rrrupdate)rWrunique_rtypers rXget_used_resourcesz"ResourceCatalog.get_used_resourcesesU%(UU$($;$A$A$C$C ( ( JQ %% h''' rZc|tjkrdS|tjkrdS|tjkrdSt d|)NGSPShzNo prefix for resource type )rrrrr)clsrs rXrzResourceCatalog._get_prefixlsR O7 7 74 O3 3 33 O3 3 34G GGHHHrZr font_family font_stylec|stddt|}iddddddddddd dd d d d d d d d dd dd dddddddddddddd}|ddD]&}|d}||}||jvr|j|cS|tvrV|dvrdn|}||} | |jvr0t|jdz} t| | ||j| <|j| cS| |} | rV| dvrdn|}| |} | |jvr0t|jdz} t| | ||j| <|j| cS(td|d|)a Resolve a family+style to a concrete font instance from the font registry. Behavior: - Exact match (family.lower() + style.upper()) in registry: return it - If `family` names a core font: add CoreFont to registry (if missing) and return it - If `family` is an alias/generic: translate to a core font, add to registry (if missing), and return it - Otherwise: raise KeyError Notes: - For Symbol/ZapfDingbats, style is forced to "" (they don't support B/I). zEmpty font familyrz sans-serif helveticaz sans serifarialverdanatahomazsegoe uiseriftimesztimes new romangeorgiacambriagaramond monospacecourierz courier newconsolasmonacosymbol zapfdingbats)r,r-z zapf dingbatsz'",>r,r-r zNo suitable font for family=z, style=) KeyErrorrrupperstripsplitrnrrrrget) rWrrralias candidatefamilyfontkey core_stylerrmappeds rXget_font_from_familyz$ResourceCatalog.get_font_from_familyvs 0.// /z//112233 +  +  [  {  k      W  W  w  w  w   ! " y# $ 9% &  ' ( i) ,*+1   6%**,,22599??DD / /I__&&,,U3399;;F (((G$,,,)'2222###)-G#G#GRRU ---d000D.//!3A.6q#z.J.JD&s+)#....YYv&&F /#)-G#G#GRRU ---d000D.//!3A.6q#z.J.JD&s+)#....  /VkVVUVVWWWrZr)r)%r[r\r]rgrecompilerrrrrrer ResourceTypesr;rr^rr(rrrrrrrr r r8rrr classmethodrrrr:r_rZrXrrsQQrz.))H =))I#$455%2:&677@AAJ ) ) ) )& c]  # </_/$////&MM,Ic|CCos6J0K,L* ?s ? ? ? ? ? ?5,5 =#% &5555 EE/>E ] EEEE C DVIICIII[I35JXJXJX,/JX G JXJXJXJXJXJXrZrceZdZdZd=dZdefdZdeezezddfd Z d>d e d e ede fd Z defd ZdeefdZeddfdedeefdZde efdZdee efdeeefdeedfdee eezffdZdee effdZdeeefde fdZ deeefdefdZ!deeeffdZ"deeefdeedfdee efddfdZ#dee efddfd Z$dee efdeeefdeee%fd!eee&e'zfd"ee eezfddf d#Z(deee&e'zffd$Z)deee%ffd%Z*d&eeddfd'Z+d"ee eezfdee efdeeefd!eee&e'zfdeee%fde,f d(Z-de e fd)Z.de/e e0e1e2ffd*Z3de e4fd+Z5defd,Z6de7fd-Z8de d.fd/Z9de e:fd0Z;dee?d:ededfd;Z@d?d<ZAdS)@rzVGenerates the final bytearray representing the PDF document, based on a FPDF instance.rrFrRNc||_g|_i|_|jj|_i|_i|_tt|_ t|_ dSrT) rpdf_objsiccp_i_to_pdf_i_resource_catalogrrrtrace_labels_per_obj_idrrsections_size_per_trace_labelrr)rWrs rXrezOutputProducer.__init__sX <> /1  " : (* 79$=H=M=M*!* rZc 0 |j}|jc|}|dkr"|t d}|jt ||j}|jr|jj |kr |jj }|j t|| }|}|}|}|jD]@}||d||dA|||} |\} } |} d} |js|} |}t7|}|j |t9||_||||d|| | | g}|D]*}||_tA|j!t8sJ|j!D]}g}|j"r/tG|j"dr| |j"|j$rNtG|j$dr9tG|j$j"dr| |j$j"|D]G}|j%tM|kr-tOd |j%d |(d H|)||j!sd|_!,| D]#}|j"| |j"$|D])}tU||j%d z j+|_,*|j-j.j/D]$}||%d z |_0%||_1| |_2||_3|j4rJd |j4|j5rJdtM|j5|j D]}tA|tlrd}n@tM|j4|j5|j+<|j78|j+}|r\|9|5|:|;|jdddn #1swxYwY|:|;|j|<|j=r=t}t~|j4|j=|j@|jA|jB|jC|_4|j4S)z This method alters the target FPDF instance by assigning IDs to all PDF objects, plus a few other properties on PDFPage instances Nrrembedded_files file_spec)pages_root_objfirst_page_objsig_annotation_objxmp_metadata_objstruct_tree_root_objoutline_dict_objrdestz'Invalid reference to non-existing page z present on page z: r z@Nothing should have been appended to the .buffer at this stage: z.No offset should have been set at this stage: )rQ)DrrQrrrgenerate_passwordsr^rbr_min_pdf_versionrArra_add_pages_root _add_catalog _add_pages_add_annotations_as_objectsrG _add_pdf_objrH_insert_resources_add_structure_tree_add_document_outline_add_xmp_metadata _compliance _add_info_add_encryptionrr)r_finalize_catalogrrrrOhasattrrrrrrextendrrpage_refstruct_builderdoc_struct_elemkpgrrrrrrPrDr3 _trace_size_outrY_log_final_sections_sizes _sign_keyr&r5 _sign_cert_sign_extra_certs_sign_hashalgo _sign_time)rWrrrbrIr page_objsrK embedded_filerMrN outline_itemsrLrrrdestspage_objannot page_destsrO outline_item struct_elempdf_obj trace_labels rX bufferizezOutputProducer.bufferizes# y  ! -37<<>>G"}}// $@@  " 5 5c'll C C C&  # C'8;FF1BK Y{33444--//'')) OO%% !==??!0 F FM   m-= > > >   m5577 E E E E y)))#7799*.*D*D*F*F'-1133 (~~''H--// && T"""'y11  )$Q<1-!5-    ')! ' 'H,HOhox88 8 88! ) )35 :6uz=996"))%*55578wuw778uw|];;8"))%',777&D'#i..88(}dFV}}iqiwiwiyiy}}}9 Z((((? '"&) 0 0L , \.///  D#$q(DMM  .>@ F FK&{'>'>'@'@1'DEKNN&  ,  \ \ [dk [ [ \ \   P P OC >wzJJ  W%%k22II))DT+UUVVVV &&((( > & &#DK{s/S>>T T datact|ts9t|tst|}|d}|xj|dzz c_dS)zAppend data to the bufferlatin1 N)rr9r^r@r)rWrzs rXrgzOutputProducer._outVsZ$&& )dC(( !4yy;;x((D te|# rZrwrxc|xjdz c_|j|_|j||r||j|j<|jSr|)rrrArrD)rWrwrxs rXrVzOutputProducer._add_pdf_obj^sS q [  W%%%  D8CD ( 5{rZc|j}t|jt|j}|||S)N)rr)rr pages_count_dimensions_to_mediaboxdefault_page_dimensionsrV)rWrrIs rXrRzOutputProducer._add_pages_roothsMy%"-d.JKK    .)))rZc#Ktd|jjdzD]R}|jj|}||ks"Jd|d||VSdS)Nr zpage_obj.index()=z != page_index=)rrrrr)rW page_indexrrs rX_iter_pages_in_orderz#OutputProducer._iter_pages_in_orderqs49#81#<==  Jyz2H  J...6(..""6666/..NNNN   rZr_slicecH|j}g}t||D]}|jdkr!|jrt ddddd|_||jkr&t||_ | |d| |t|jtsJt!|j|j }| |d||_|S) Nz1.3z/Groupz /Transparency /DeviceRGB)rz/Sz/CSrr rr5)rrrrballow_images_transparencyrrrrrrrVrrr2rr*r6)rWrrrnrrcs_objs rXrTzOutputProducer._add_pageszs6y#% T668899&A ' 'H%''D,J'!)&olSS""""""$$(DDD%|j0d%d2rtg|j0d%d}n|j4}|d&kr"tD#d'|(j5|||<|j6||<t?|rd(nd)| (j7j8|r|rts|ntu(*}| |dtw|g|_<g}d+tfd,tzfd-)(jD]{\}}|2t |jt&rt)|jdkr:|d |d.d d )fd/|jDd|td0t)|dd |dd} | | d| |_|r|rd1}d2}d}(j>r (j>\}}}d3t|D}td4|d5|d6|d7|d8|d9t)|d:d |d;d}td<|_@t|d8|d=|_Atd>|d?|d@|dA|_C| |d||_Dt} |rE(j>r>(j>\}}}t|dB| _Gt|dB| _H|| _I| | d| |_C(j7}!t| |!_J| |!d|!|_K|sdCgdDzdDzdEz}"|D]8\}#}$t|$dFz |"|#dEz<t|$dz|"|#dEzdGz<9d |"}%t|%dHd}&| |&d|&|_Mt|I}'|rtdJ|'_O| |'d|r|'|!_Pn|'|!_Q(jjRS(jjTS(U |S)KNc|jSrT)r)r,s rXrz+OutputProducer._add_fonts..sdfrZrzType 3 fonts with color glyphs are not supported is more than 255 glyphs are rendered. set FPDF.render_color_fonts=False or use less color glyphs.latin-1r5fontsr<02Xz> .sO7~7~hlD 8H8H8U8U8Y8Y8[8[8a8a8c8c7~7~7~7~7~7~rZz> z/CIDInit /ProcSet findresource begin 12 dict begin begincmap /CIDSystemInfo <> def /CMapName /Adobe-Identity-UCS def /CMapType 2 def 1 begincodespacerange <00> endcodespacerange z beginbfchar zGendbfchar endcmap CMapName currentdict /CMap defineresource pop end end)Symbol ZapfDingbatsWinAnsiEncodingType1)rjrkrlrrc3K|]L}dt|dt|ddVMdS)'z' (zunicode-escaperhN)rr@rJ)rxs rXrz,OutputProducer._add_fonts..so$$SCFFRRs1vv}}5E'F'F'M'M'O'ORRR$$$$$$rZ z , ... (and z others)z+Font %s is missing the following glyphs: %sT)notdef_outlinerecommended_glyphs)FFTMGDEFGPOSGSUBMATHhdmxmetasbixCBDTCBLCEBDTEBLCEBSCzSVG CPALCOLR)rcZi|]'\}}||j|j(SrT)r getGlyphIDr)rrchar_idr,s rXrz-OutputProducer._add_fonts..+sB111&w(T[33E4DEE(((rZType0z Identity-HcidzJGlyph CID %s exceeds 0xFFFF and cannot be encoded in a 2-byte CID font: %s CIDFontType0 CIDFontType2)rjrkrmrnrrRcL|dkrd|dz dz z}d|dzz}|d|dS|dS)Nriirii04Xr_)r code_highcode_lows rX format_codez.OutputProducer._add_fonts..format_codemsR''$*g.?B-F$F #)Wu_#="+??????%+++rZrc3.K|]}|VdSrTr_)rrrs rXrz,OutputProducer._add_fonts..}s-7d7dd D8I8I7d7d7d7d7d7drZz/CIDInit /ProcSet findresource begin 12 dict begin begincmap /CIDSystemInfo <> def /CMapName /Adobe-Identity-UCS def /CMapType 2 def 1 begincodespacerange <0000> endcodespacerange rIdentityc(g|]\}}d|dd|dS)rrz> rr_)rrrs rXrz-OutputProducer._add_fonts..sB###%D#0D//////###rZzY/CIDInit /ProcSet findresource begin 12 dict begin begincmap /CIDSystemInfo <> def /CMapName /-zO-UCS def /CMapType 2 def 1 begincodespacerange <0000> endcodespacerange z begincidchar zHendcidchar endcmap CMapName currentdict /CMap defineresource pop end endCMapz-UCSz<< /Registry (z ) /Ordering (z) /Supplement z >>rr r|r= CIDFontType0C)Vrrrrrr color_fontr _nextrrrVr*rr@r6rrrrrrrrrrrtrrrrriget_all_glyph_namesmissing_glyphsLOGGERwarningftsubsetOptions drop_tables Subsetterpopulaterr saveseekreadis_cff is_cid_keyedr startswithisdigitrglyph_idr7rdesc missing_width_cid_font_widths_tt_font_widthsr)rsr^cff_rosr(rr c_map_namer.rurlr}r-rrr font_namervrrwr1rj font_file3 font_file2pick cache_clear get_glyphclose)*rWrrrfont_objs_per_index color_glyphbfCharr code_mappedto_unicode_obj t3_font_objrl core_font_objfontname glyph_namesmsgoptions subsetter code_to_glyphoutput ttfontstreamcomposite_font_obj is_cff_cid code_to_cid cid_widthsr cid_font_objrrr cid_mappingencoding_cmap_objcid_system_info_objfont_descriptor_objcid_to_gid_listccglyph_icid_to_gid_mapcid_to_gid_map_objfont_file_cs_objr,rs* @@rX _add_fontszOutputProducer._add_fontss BD49?11339L9LMMMI I D$((> T_> ;$t++'V$(?#9K)-):):(%0%6%=%=i%H%H%)Y%7 **K&&%'*.+*;*;*=*=  &E; )%-??&u}--22 MMDKDDD7~7~pup}7~7~7~0~0~DDD"2v;;776??(fY''-""0!!.':::*4?;; )01B)C)C &..+*) !!+w777.9#DF+$))E y(BBB&% !(#ty8!!! !!-999.;#DF++D'**z 0TY00#k==?? t*++a//))$$!%!4SbS!9$$$C4.//"44TS1D-E-E-JTTTTNNExQT#*$SWXXX##(((##(%.w77 ""+"666  ---1111*.+*;*;*=*=111 !   ((( A%{{}} &-#x,&&&"!!"4g>>>.@#DF+"[>T-> 8< 7; <"$K!#J.2k.?.?.A.A<<*{ =$!,77>>1 % 0 4 < < > >1#&e&6qrr&:";";CC"'.C<<"NN l # $  %36 K0*/*; 3&.8LNNn& /&3*43(444,T22    !!,8886> ~6N6N"3 ,,,,,,+/+*;*;*=*=  &E; )%-??&u}--22 MMiKiii7d7d7d7dV[Vc7d7d7d0d0diii"2v;;776??(fY''-""0!!.':::0>"-*D+*D&H)H!"J|F9=6(J##)/ 0A0A0C0C)D)D###K)9"-5 "" +3 "" ,6 ""+3""6>"" #;//"" "ww{33"""(!&++-))%0.2&\\%*37#44h44444%0;>gggggXbggg;;%7%%&7AAA2C&/&3oo#@$,@59\2Hh 3O'4':':'<'<JJ G25gl2C2CQ/69'D.6I6IQ 33%'WW_%=%=N*:!/!6!6x!@!@4***&%%&8'BBB6HL3#0,#G#G#G E/3O/D/D$,!!"2G<<<F5E'225E'2  ,,... %11333 ""rZci}t|jjjdD]R}t t |ddkr1|||t t |d<S|S)Nc8tt|dS)Nr)r>r)rs rXrz,OutputProducer._add_images..s4SQTXCVCVrZrusagesrr)rr image_cacheimagesrr>r _add_image)rWrrs rX _add_imageszOutputProducer._add_imagess46 I ! ( / / 1 17V7V    O OCCX''!++:>//#:N:N"4SX#6#67!!rZimg_infoc tt|d}||jvr |j|Sd}|jjjD]\}}||kr|}n|Jt|tt|dtt|d}| |d}||j|<|S)z~ Returns the PDF object of the ICC profile indexed iccp_i in the FPDF object. Adds it if not present. iccp_iNdpncs)r2rUrViccp) r>rrBrr icc_profilesrrTr^rV)rWrr iccp_contenticcp_criccp_obj iccp_pdf_is rX _ensure_iccpzOutputProducer._ensure_iccps c8H-.. T) ) )'/ / .;AACC  IFA{{% ''' !3((3//    &&x88 '1V$rZrc t|d}|rdnt|d}d}|rdn|d}|dkr-tddt |ddzd z g}nW|C||}td t |t d d g}n|d kr |ddurd}d|vrtt |d}d|dd|dd}tdtt|dtt|dtt|d|tt|dtt |d||| }| |d|d<|j j rKd|vrG|sEd |d} ||d|dd!d"|d| |dd#|_t!|trd|vrt!|jtsJt%tt|d|j j$} | | d|jt+| j|S)%NrMrrIndexedz/Indexedrpalrr z /ICCBased0R DeviceCMYKinvertedTz[1 0 1 0 1 0 1 0]rJrdpz /BitsPerComponent bpcrImagerzrnhf) rjr2rFrGrHrIrNrJrKrMrrsmaskz!/Predictor 15 /Colors 1 /Columns DeviceGrayr)rnr(rr&r)r%rzr5)rRr3r(r)rrr^r>rr9rrVrrrrLrrHr*r6rrr) rWrrMrHrJrrrKimg_objr% pal_cs_objs rXrzOutputProducer._add_images$((<0011 6@.Vddd4PT:FVFV #;();); ) # #"\c$u+.>.>!.Ca.G+IJKK **400J"KZ#c((C#PQQKK L ( (J4'', t  #tH~..FJDJJJ4;JJJ %f..sDI&&T#Y''##Ce55Cc++%!    **7H==X 9 . 7d??:?@T#Y@@B!__cc&c M  GN k8 , , ?{1J1Jg18<< < <<)eT%[11DIdS)zSAppend soft-mask Form XObjects after patterns exist so we can resolve /Pattern ids.N)rrCr_pathget_resource_dictionaryrrAr)rWrrrrs rX_add_soft_maskszOutputProducer._add_soft_masksXsc4G , ,I"+/"I"I&(=?Q##I  M  + + + +  , ,rZc|jjjD]I\}}t|dds||dd|_|||JdS)z\Ensure isolated blend forms are part of the XObject set before other resources rely on them. _registeredFrTN)rrCrr rVr7 setdefault)rWrrrs rX#_register_form_xobject_placeholdersz2OutputProducer._register_form_xobject_placeholdersest#i9G : :NE77M599 +!!'8444&*#  ) )% 9 9 9 9  : :rZshading_objs_per_namerc|jjjD]6\}}t|dd}||||||||_7dS)z@Populate resource dictionaries for isolated blend Form XObjects. _blend_groupN)rrCrr r4r) rWrrrr:rrrrs rX_finalize_form_xobjectsz&OutputProducer._finalize_form_xobjectsosh)5C  JAw!'>4@@K&$/$G$G*))'& %%!  rZct}|jjtjD]\}}t |tttfsJ| D]}| |d| }| |d|||<|S)Nfunctionr.) rrrCrrrrr!r$r" get_functionsrVget_shading_object)rWr:r.rr? shading_objs rX _add_shadingszOutputProducer._add_shadingssBM--!Y8BB  #   6 6MGTg';'GHH H HH#1133 8 8!!(J7777181K1K1M1MK   k9 5 5 5*5 !$ ' '$$rZct}|jjtjD]\}}t |tsJ||d|||<| rz| | tj d|jj dd|jjz|S)Nrrr r)ry)rrrCrrrrr#rVget_apply_page_ctm set_matrix get_matrixr translationr(rrd)rWrrrs rX _add_patternszOutputProducer._add_patternss4?MM!Y8BB  #   MGTgw// / //   gy 1 1 1*1 !$ '))++ ""&&((+A |<<UQ"U%%U49;''(%$rZrnc0   }  |   |  | jj r' | }|D] }||_ dSt|dD]\ } fdjj  tjD} fdjj  tjD} fd|D}fdjj  tjD} fdjj  tjD} ||||| |_ dS)Nr )rrcVi|]%}t|t|&Sr_r)rfont_idrs rXrz4OutputProducer._insert_resources..s=,,,LL"5c'll"C,,,rZcVi|]%}t|t|&Sr_rM)rimg_idrs rXrz4OutputProducer._insert_resources..s=+++KK!3CKK!@+++rZcti|]4\}}|jjtjv1||5Sr_)rrCrrr)rgfx_name gfx_staterrWs rXrz4OutputProducer._insert_resources..s\///-9y2II#_%@irZcVi|]%}t|t|&Sr_r)r shading_namer:s rXrz4OutputProducer._insert_resources..A...$ %%'.rVrZ)rr9r1rJr rCr=r5rsingle_resources_object_add_resources_dictr enumeraterCrrrrrrr)rWrnrresources_dict_objrrpage_font_objs_per_indexpage_img_objs_per_indexpage_gfxstate_objs_per_namepage_shading_objs_per_namepage_pattern_objs_per_namerrrrr:s` @@@@@rXrWz OutputProducer._insert_resourcess!--// 001CDDD!%!4!4!6!6 $ 2 2 4 4"oo  68M  !% 2 2 4 4 $$  " ! !       "$9;M    9 ,3 !%!9!9#"&%% "" & 8 8%7"" 8 8*39A)F)F)F( ( % X,,,,#'9#>#U#U#_%9$$,,,( ++++"&)"="T"T#_%=##+++' /////1G1M1M1O1O///+....(, (C(Z(Z#_%<))...* ....(, (C(Z(Z#_%<))...*&*%=%=,+/.. &&""E( ( rZcd}d\}}} } } |r8tdt|D}|r8tdt|D}|r+td|D} |r8tdt|D} |r8tdt|D} t|||| | | } || | S) Nz$[/PDF /Text /ImageB /ImageC /ImageI])NNNNNcDi|]\}}d|t|jS)z/Frr)rrfont_objs rXrz6OutputProducer._add_resources_dict..s>'x!LL'(+"6"6rZcDi|]\}}d|t|jS)rrd)rrr,s rXrz6OutputProducer._add_resources_dict..s>&w!LL''*"5"5rZcDi|]\}}d|t|jSrrd)rrrs rXrz6OutputProducer._add_resources_dict.. s>*lJJ  8 8rZcDi|]\}}d|t|jSrhrd)rrrBs rXrz6OutputProducer._add_resources_dict..>)kJJ  7 7rZcDi|]\}}d|t|jSrhrd)rr pattern_objs rXrz6OutputProducer._add_resources_dict..rjrZ)r+r,r-rr.r)rrrr*rV) rWrrrr:rr+r,r-rr.r resources_objs rXrZz"OutputProducer._add_resources_dicts:8T5h Wg  +12E2K2K2M2M+N+ND  *01C1I1I1K1K*L*LH " ".D.J.J.L.LK ! -34I4O4O4Q4Q-R-RG ! -34I4O4O4Q4Q-R-RG%#     -(((rZc|jjrdSd}|jjD]}||}||d|S)zDBuilds a Structure Hierarchy, including image alternate descriptionsNstructure_tree)rrbemptyrV)rWrMrws rXrXz"OutputProducer._add_structure_tree-sf 9 # ) ) + + 4#y/ 9 9G#+'.$   g'7 8 8 8 8##rZc|jjsdSd}g}t|jjD]E}t|tr|}n||||dF||fS)N)Nr_document_outline)r_outliner rrrrV)rWrNrprws rXrYz$OutputProducer._add_document_outline8sy! 88<57 )$)*<== ; ;G'#455 .#*  $$W---   g'9 : : : :..rZc|jj}|s |jjr|}|sdSdt dd|d}t |}|||S)Nz z )r xmp_metadatar[_build_xmp_from_inforr;rV)rWxmp_srcxpacketrws rXrZz OutputProducer._add_xmp_metadataGs)( 2490 2//11G 4vc&kkvvV]vvv )) '"""rZc t|jddpd}t|jddpd}t|jddpd}|rt|tr|g}t|jddpd}|rt|tr|g}t|jddpd}t|jddpd}t|jdd}d}t|tr<|jr|n|}|tj}|jj } d td tfd } t d d ddddtj} t j tj} || kr-| d} | d}n0|p| }| d} | d}gd}|r"| d| |d| rf| d| | d| d| |d| d| |d|r"| d| |d|r7d |}| d| |d| d| ry| dt| jd| jr'| d | | jd!| jd"kr| d#|r|d$d%| |zd&zd'gz }|r|d(d%| |zd&zd)gz }|rQ| d*|D]$}| d+| |d&%| d,|gd-z }d. |S)/NrrrrrrrrrdrRcr|dntt|d}|ddS)zDReturn XML-escaped text suitable for XMP (attributes or text nodes).NrT)quoterz') _html_escaper^replace)rdrcs rXescz0OutputProducer._build_xmp_from_info..escgs6)BBc!ffD)I)I)IE==h// /rZi r)tzinfoseconds)timespec)z4z z! z z z z! z z z )z z z r)r rrr^rr astimezoner utcr[now isoformatrrrpart conformance)rWrrrr creator_toolrcdatecreation_date_utcpdfar~EPOCHr xmp_create xmp_modify create_dtparts keyword_listrs rXrvz#OutputProducer._build_xmp_from_infoTs 7D117R$)Y55;Hd339r  j-- XF49j$77=2  " 8S11 " zHty)T::@b 49j$77=2 ?D99  eX & & K). M5;K;K;M;M  1 < $*<>>  *D)T224400T:t44D)T22T:t44'    (###s! AAArAc|jjr7|jj}|}|||SdSrT)rrQget_encryption_objrV)rWencryption_handlerrws rXr]zOutputProducer._add_encryptionsI 9 & !%!< (;;==G   g & & &NtrZc|jj}|sdS|D]#}|jr||j$t |S)zshould be added in _add_catalogN)rr#rrVr))rWr# output_intents rX_add_output_intentsz"OutputProducer._add_output_intentss\1 4+ E EM0 E!!-"CDDD'''rZc|j}tt|dd|j|j|j}||_|||S)Nr)rrrr) rrr rrrrr#rV)rWrrs rXrSzOutputProducer._add_catalogsmy vt,,(n#6    &*%=%=%?%? " +&&&rZrrIrJrKrLrMrNc |j}||_||_||_||_|r=t jt jz} tt|g| |_ |j tvr(t|jgt|j } nAt|jdddtt!t"|j dz g} t%| |_|rt)ddi|_|js|jri} |jr^d|jD} t)dt%| i| d <d |jjD} | rt%| |_|jr>g}|jD]\}}|jd krt7d |d t9|dr|js^|jJ|jdz }d |cxkrt=|jkr,nn)t|j|jj|_|tA|d!|j"|jd|!|r.t)dt%tG|i| d<t)| |_$fdtK|&D}|r5|jd's|(d d|r7t)dt|!i|_)dSdS)NrrJrIdz/Markedtruecg|]Q}t|d|jRS)r)r-basenamerYrHref)rros rXrz4OutputProducer._finalize_catalog.. se###%!!7!7!9!9::DDFFhhI`I`IbIbIfhh###rZz/Namesz/EmbeddedFilescg|]<}|t|j=Sr_)globally_enclosedrrHr)refs rXrz4OutputProducer._finalize_catalog..sM%%%++--%BLLNN-..%%%rZrzNamed destination 'z6' was referenced but never set with set_link(name=...)rar Trr rz/Destscg|]A\}}|x|dtBS)Nr)rrrY)rrpagelabels rXrz4OutputProducer._finalize_catalog..6s^   4,,...; 0 08EOO--.. 0 0;;;rZz0 <<>>z/Nums)*rrr$r"r rSIGNATURES_EXIST APPEND_ONLYrr)r zoom_mode ZOOM_CONFIGSrrr^r>ryrrrrrGnamed_destinationsr%rrrr_rarrr-rYrQrr!r[rrinsertr&)rWrrIrJrKrLrMrNrflags zoom_confignames_dict_entriesfile_spec_namesglobal_file_specs dests_namesrrOrr&rs @rXr^z OutputProducer._finalize_catalogs6y* '; $/ /   !2]5NNE$,!3 455%%%K ! >\ ) ))**dn-KK )**D//#566 K#+;"7"7   B$,i-@$A$AK !  . =$"9. =13 " B##)-)<###8@x88988"#34%%"i6%%%! %B&./@&A&AKO& )+ "&"9"?"?"A"AJD$'1,,+n$nnn #444UDMU#/;;;%)%5%9  <<<%>%@%@AA    ,tz!};;== ,   q( + + +  &.(;//99;;<''K # # #  rZrc#Kt|j}dV|j|xxt|j|z z cc<dSrT)rrrE)rWr prev_sizes rXrfzOutputProducer._trace_sizeCsR $$   *5111S5E5E 5QQ11111rZctd|jD].\}}td|t |/dS)Nz4Final size summary of the biggest document sections:z- %s: %s)rdebugrEr _sizeof_fmt)rWr section_sizes rXrhz(OutputProducer._log_final_sections_sizesIsg KLLL#'#E#K#K#M#M G G E< LLUK ,E,E F F F F G GrZ)rrFrRNrTr)Br[r\r]rgrerryr9r^rgr,r;rrVrrRr9rrslicerrTrrUrrrrirr robjectrrr1r5r9r#r$r"r=rCrJrWr*rZrXrrr<rrYr;rZrvrr\r]r)rrrSr^rrfrhr_rZrXrrsS\\ - - - -A9AAAAF$*S0$T$$$$@D /7} hw&7*/q$DM0 "Xm-D " " " "R#!%c:o!6R#!%S,%6 7R# $CN3 R# c7\)) * R#R#R#R#h "T#z/2""""T#v+%6309tCK09Z9999v&S,%6 7&&&& , $S,%6 7 , $CN3 ,!j1 ,  , , , ,:"&sJ"7: :::: j1!%S,%6 7 $CL1  $C;)>$>?  "#w'="=>  ( %tC;)>$>? % % % %%tCL1%%%%$G4=GTGGGGR@!#w'="=>@!j1@!%S,%6 7 @ $C;)>$>? @ $CL1 @ @@@@D $Xi%8 $ $ $ $ / x)*H5J,KK L / / / / 8N#;    Y cY Y Y Y v7(*@!A(Xh%7(((( j    __%_ _ %]3 _ #>2 _'y1_##45_ ____BRR$RRR^R GGGGGGrZrFrrrErnr(keep_aspect_ratiorpdf_height_to_fliprRc |r|||||\}}}}|r |}||z |z } n| }||z} d||zdd||zdd||zdd| |zdd|dd S)Nzq .2fz 0 0 rz cm /Irz Do Q)scale_inside_box) rrrErnr(rrrstream_hstream_ys rXstream_content_for_raster_imagerOs7**1aA66 1a%)A-2q5 QY7  E!17   I5  $u,5  3i   rZr,c d}i}i}d}d}d}tt|jd}|D]}|J||} | |dzkr|j|krv|j||dkr/||g|jn(|||}||jg||<d}d||<nB|r| }|jg||<n |||jd}n| }|jg||<d}| }|j}d} d} d} |} t|D]a\}}t|}|| kr+| s)|| vs|d kr|| vr| |=|| ||z|| <||=n|} ||z} || vr|d k} | |=| dz} _d} bg}t|D]\}}tt|dkr8|d |d |t|zdz d |d]|d |d d d |Dd dd |dS)NrrFc|dSr|r_)items rXrz!_tt_font_widths..qs tAwrZrr Trr [ c3NK|] }tt|V!dSrTr^rrr(s rXrz"_tt_font_widths...'@'@CFF '@'@'@'@'@'@rZ ] rrr) rrr rrr8rpoprrr)r,rangeidrange_range_intervalprevcid prevwidthintervalrr cid_mappedprevknextkprevintrirdwscwsrns rXrrhsG#%F&(NGIH&**,,2F2FGGG H HF&&   E] 'A+ & & I--$w(:::%%gr2299%:KLLLL7O'')))%G'0%2C&DF7O*.w''>(G','8&9F7OO7O**5+<===  G$01F7OH% E EG B ''2"gg ::g:1B;;#''BwwqE"5MF1I5F5Mq EC 77AgG1 QJEEGGA ''HH2 s2ww<<1   HH666QR[1_66r!u66 7 7 7 7 HHFFFsxx'@'@R'@'@'@@@FFF G G G G rwwqzz   rZrc ~d}i}i}d}d}d}t|D]\}}||dzkr||krg|||dkr*||g|n#|||}||g||<d}d||<n3|r |}|g||<n|||d}n |}|g||<d}|}|}d} d} d} |} t|D]a\} }t |}| | kr+| s)| | vs|dkr| | vr| | =|| || z|| <|| =n| } | |z} | | vr|dk} | | =| dz} _d} bg}t|D]\} }t t |dkr8|d| d| t |zdz d|d]|d| d dd |Dd d d |dS)NrrrFr Trrrc3NK|] }tt|V!dSrTrrs rXrz#_cid_font_widths..rrZrrrr)rrr8rrrrr)rrrrrrrrrFrrrrrdrrrns rXrrsG#%F&(NGIHZ--//00 U 7Q;   !!F7OA...%%gr2299%@@@@7O'')))%G'0%&8F7O*.w''2!G',gF7OO7O**5111 G$gF7OH E EG B ''2"gg ::g:1B;;#''BwwqE"5MF1I5F5Mq EC 77AgG1 QJEEGGA ''HH2 s2ww<<1   HH666QR[1_66r!u66 7 7 7 7 HHFFFsxx'@'@R'@'@'@@@FFF G G G G rwwqzz   rZrc"|\}}d|dd|ddS)Nz[0 0 rrrr_)rrrs rXrrs+$Hi 28 2 2 2) 2 2 2 22rZBnumsuffixcbdD]%}t|dkr |d||cS|dz}&|dd|S)N)rKiMiGiTiPiEiZiiz3.1fz.1fYi)abs)rrunits rXrrsa> s88d??...f.. . . . t  ! ! ! ! !!rZpathresource_catalogc*t||d}||_t d|_t d|_t||_ d|_ |S)zSConverts a PaintedSoftMask into a PDF XObject Form suitable for use as a soft mask.rr=rPFormz5<>) r*renderr@r3r(rrrjr)get_bounding_boxb_boxr)rrrs rXrrsw 4D(E(E(L(LY(W(WXXXGGM ??GL6llGOT224455GMKGM NrZrr?c@||}t|d}||_d|_t d|_t d|_|}t||_ d|_ |S)zNConvert a blend group into a Form XObject with an isolated transparency group.rr=FrPrz+<>) rr*r@r<r7r(rrrjrr)rr)rrstreamrbboxs rXrr s\\* + +F i(@(@AAAG GG ??GL6llGO  ! ! # #DTNNGMAGM NrZ)Fr N)r)rgloggingr;abcrr collectionsrr contextlibrrr htmlr r|ior fontToolsr r annotationsrrdrawingrrdrawing_primitivesrenumsrrrrerrorsr font_type_3rrrrrimage_datastructuresr line_breakroutlinerrr rr!r"r#r$signr%r&syntaxr'r(r)r*r+r,r-r.r/r0rr1rr2rutilr3r4endesiver5 ImportErrortypingr6r7r8r9r:r;r<r=r>r?r@ encryptionrArBrCrDrErrFprefsrG transitionsrH getLoggerr[rrrPrarir}rrrrr*r1r;rrTrYrrrrrr^rr=rrryrRrrrrrrrrrr_rZrXrsU  $#######00000000%%%%%%''''''''''''''((((((6666666611111111))))))VVVVVVVVVVVV!!!!!!""""""0000000000111111666666QQQQQQQQQQ<<<<<<<<<<<<))))))))                            ,+++++++ FFF                      (22222222IIIIIIII++++++++((((((((((((''''''  8 $ $" ) """""s"""55555 555(CCCCCiCCC.IY Y Y Y Y 9Y Y Y x+++++i+++222222222$////////:9&%%%%%$%%% #####%###*7*7*7*7*7!*7*7*7Z)))))$))):77777777tk'k'k'k'k'ik'k'k'\     9    ? ? ? ? ?9 ? ? ?-----(---`E"E"E"E"E"E"E"E"Pc3j)Y UV aXaXaXaXaXaXaXaXHIGIGIGIGIGIGIGIGd$$*.         ! 2B'BcBBBBJ<c3h<C<<<<~3eUl(;33333 ""U"C"#""""  - ' ;J        +:       sC CC