Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 1øªjëÈã@sØddlZddlZddlmZddlmZddlmZmZmZm Z m Z m Z m Z m Z mZmZddlmZddlmZmZddlmZdd lmZmZmZdd lmZdd lmZ dd lm!Z!m"Z"m#Z#dd lm$Z%ddlm&Z'ddlm(Z)ddlm*Z+ddlm,Z-ddl.m/Z/m0Z0ddl1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:m;Z;mZ>m?Z?m@Z@mAZAmBZBmCZCmDZDddlEmFZFmGZGddlHmIZIeJeKeeKe edffdœdd„ZLGdd„de6ƒZMGdd„dƒZNGdd„de eefƒZOdS) éN)Úabstractmethod)Údatetime) ÚAnyÚDictÚIterableÚIteratorÚListÚMappingÚOptionalÚTupleÚUnionÚcasté)Ú Encryption)Ú PageObjectÚ _VirtualList)Ú index2label)Údeprecate_with_replacementÚlogger_warningÚparse_iso8824_date)ÚCatalogAttributes)ÚCatalogDictionary)ÚCheckboxRadioButtonAttributesÚGoToActionArgumentsÚUserAccessPermissions)ÚCore)ÚDocumentInformationAttributes)ÚFieldDictionaryAttributes)ÚPageAttributes)ÚPagesAttributes)Ú PdfReadErrorÚ PyPdfError)Ú ArrayObjectÚ BooleanObjectÚByteStringObjectÚ DestinationÚDictionaryObjectÚEncodedStreamObjectÚFieldÚFitÚ FloatObjectÚIndirectObjectÚ NameObjectÚ NullObjectÚ NumberObjectÚ PdfObjectÚTextStringObjectÚ TreeObjectÚViewerPreferencesÚcreate_string_objectÚis_null_or_none)Ú OutlineTypeÚ PagemodeType)ÚXmpInformation.)ÚdÚsizeÚreturncCs4|dkrtdƒ‚d|}|dd…}tjd|ƒdS)Nézinvalid size in convert_to_intsz>qriøÿÿÿ)r ÚstructÚunpack)r8r9©r>ú2/tmp/pip-build-_d5lkt3n/pypdf/pypdf/_doc_common.pyÚconvert_to_int^s  r@c@sfeZdZdZddœdd„Zeeedœdd„Zeeedœd d „ƒZ eeedœd d „ƒZ eeedœd d„ƒZ eeedœdd„ƒZ eeedœdd„ƒZ eeedœdd„ƒZeeedœdd„ƒZeeedœdd„ƒZeeedœdd„ƒZeeedœdd„ƒZeeedœdd„ƒZeeedœdd „ƒZeeedœd!d"„ƒZeeedœd#d$„ƒZdS)%ÚDocumentInformationa… A class representing the basic document metadata provided in a PDF File. This class is accessible through :py:class:`PdfReader.metadata`. All text properties of the document metadata have *two* properties, e.g. author and author_raw. The non-raw property will always return a ``TextStringObject``, making it ideal for a case where the metadata is being displayed. The raw property can sometimes return a ``ByteStringObject``, if pypdf was unable to decode the string's text encoding; this requires additional safety in the caller and therefore is not as commonly accessed. N)r:cCstj|ƒdS)N)r&Ú__init__)Úselfr>r>r?rBuszDocumentInformation.__init__)Úkeyr:cCs|j|dƒ}t|tƒr|SdS)N)ÚgetÚ isinstancer0)rCrDÚretvalr>r>r?Ú _get_textxs  zDocumentInformation._get_textcCs,|jtjƒr(|jtjƒp*|jtjƒjƒSdS)zŸ Read-only property accessing the document's title. Returns a ``TextStringObject`` or ``None`` if the title is not specified. N)rEÚDIÚTITLErHÚ get_object)rCr>r>r?Útitle~s (zDocumentInformation.titlecCs |jtjƒS)z>The "raw" version of title; can return a ``ByteStringObject``.)rErIrJ)rCr>r>r?Ú title_rawŒszDocumentInformation.title_rawcCs |jtjƒS)z¡ Read-only property accessing the document's author. Returns a ``TextStringObject`` or ``None`` if the author is not specified. )rHrIÚAUTHOR)rCr>r>r?Úauthor‘szDocumentInformation.authorcCs |jtjƒS)z?The "raw" version of author; can return a ``ByteStringObject``.)rErIrN)rCr>r>r?Ú author_raw›szDocumentInformation.author_rawcCs |jtjƒS)z£ Read-only property accessing the document's subject. Returns a ``TextStringObject`` or ``None`` if the subject is not specified. )rHrIÚSUBJECT)rCr>r>r?Úsubject szDocumentInformation.subjectcCs |jtjƒS)z@The "raw" version of subject; can return a ``ByteStringObject``.)rErIrQ)rCr>r>r?Ú subject_rawªszDocumentInformation.subject_rawcCs |jtjƒS)ac Read-only property accessing the document's creator. If the document was converted to PDF from another format, this is the name of the application (e.g. OpenOffice) that created the original document from which it was converted. Returns a ``TextStringObject`` or ``None`` if the creator is not specified. )rHrIÚCREATOR)rCr>r>r?Úcreator¯s zDocumentInformation.creatorcCs |jtjƒS)z@The "raw" version of creator; can return a ``ByteStringObject``.)rErIrT)rCr>r>r?Ú creator_raw»szDocumentInformation.creator_rawcCs |jtjƒS)aI Read-only property accessing the document's producer. If the document was converted to PDF from another format, this is the name of the application (for example, macOS Quartz) that converted it to PDF. Returns a ``TextStringObject`` or ``None`` if the producer is not specified. )rHrIÚPRODUCER)rCr>r>r?ÚproducerÀs zDocumentInformation.producercCs |jtjƒS)zAThe "raw" version of producer; can return a ``ByteStringObject``.)rErIrW)rCr>r>r?Ú producer_rawÌsz DocumentInformation.producer_rawcCst|jtjƒƒS)z:Read-only property accessing the document's creation date.)rrHrIÚ CREATION_DATE)rCr>r>r?Ú creation_dateÑsz!DocumentInformation.creation_datecCs |jtjƒS)zÉ The "raw" version of creation date; can return a ``ByteStringObject``. Typically in the format ``D:YYYYMMDDhhmmss[+Z-]hh'mm`` where the suffix is the offset from UTC. )rErIrZ)rCr>r>r?Úcreation_date_rawÖsz%DocumentInformation.creation_date_rawcCst|jtjƒƒS)z” Read-only property accessing the document's modification date. The date and time the document was most recently modified. )rrHrIÚMOD_DATE)rCr>r>r?Úmodification_dateàsz%DocumentInformation.modification_datecCs |jtjƒS)zÕ The "raw" version of modification date; can return a ``ByteStringObject``. Typically in the format ``D:YYYYMMDDhhmmss[+Z-]hh'mm`` where the suffix is the offset from UTC. )rErIr])rCr>r>r?Úmodification_date_rawés z)DocumentInformation.modification_date_raw)Ú__name__Ú __module__Ú __qualname__Ú__doc__rBÚstrr rHÚpropertyrLrMrOrPrRrSrUrVrXrYrr[r\r^r_r>r>r>r?rAfs>       rAc @s>eZdZUdZdZedZeedZ e e e e dœdd„ƒƒZ e e edœdd„ƒƒZe eeefeed œd d „ƒZe eeed œd d„ƒZe e ee dœdd„ƒƒZe eedœdd„ƒZe eedœdd„ƒZe dyedeefedeefeeefdœdd„ƒZe eedœdd„ƒZ dZ!ee"e#!edœdd„Z$ee#dœdd„Z%ee&e efdœdd „Z'e eeefdœd!d"„ƒZ(e)dœd#d$„Z*dzee+dfeeeeefd%œd&d'„Z,d{ee+eeeefeeee"eeeeefd(œd)d*„Z-e ed+œd,d-„Z.ee+e feeefeee"edd.œd/d0„Z/ee+e feee"edd(œd1d2„Z0eeedd3œd4d5„Z1d|eeeefd6œd7d8„Z2ee3eefe"e#d9œd:d;„Z4e ede5e6e7fdœdœd?d=„ƒZ8e e:dœd@dA„ƒZ;d}ee eee:dBœdCdD„Zefeed œdGdH„ƒZ?e#eedIœdJdK„Z@e5eedLœdMdN„ZAeee"eeBede>e fe5dOœdPdQ„ZCe ee5dRœdSdT„ZDe e"e#dœdUdV„ƒZEe e"edœdWdX„ƒZFe eedœdYdZ„ƒZGe eeHdœd[d\„ƒZId~eede e#feeeefeedd]œd^d_„ZJdeee#efedd`œdadb„ZKeeeedcœddde„ZLeeeefdfœdgdh„ZMe eeNdœdidj„ƒZOe e edœdkdl„ƒƒZPe eeeefdœdmdn„ƒZQe eRee"eSfdœdodp„ƒZTe"edœdqdr„ZUee"eSdsœdtdu„ZVd€eeeeeeSe"eSffdvœdwdx„ZWdS)�Ú PdfDocCommonzm Common functions from PdfWriter and PdfReader objects. This root class is strongly abstracted. FN)r:cCsdS)Nr>)rCr>r>r?Ú root_objectszPdfDocCommon.root_objectcCsdS)Nr>)rCr>r>r?Ú pdf_headerszPdfDocCommon.pdf_header)Úindirect_referencer:cCsdS)Nr>)rCrir>r>r?rK szPdfDocCommon.get_object)ÚindirectÚobjr:cCsdS)Nr>)rCrjrkr>r>r?Ú_replace_objectszPdfDocCommon._replace_objectcCsdS)Nr>)rCr>r>r?Ú_infoszPdfDocCommon._infocCs$tƒ}|jdkrdS|j|jƒ|S)a Retrieve the PDF file's document information dictionary, if it exists. Note that some PDF files use metadata streams instead of document information dictionaries, and these metadata streams will not be accessed by this function. N)rArmÚupdate)rCrGr>r>r?Úmetadatas   zPdfDocCommon.metadatacCsdS)Nr>)rCr>r>r?Ú xmp_metadata*szPdfDocCommon.xmp_metadata)ÚincludeÚexcluder:cCsdS)zâ Integration into Jupyter Notebooks. This method returns a dictionary that maps a mime-type to its representation. See https://ipython.readthedocs.io/en/stable/config/integrating.html Nr>)rCrqrrr>r>r?Ú_repr_mimebundle_.szPdfDocCommon._repr_mimebundle_cCsd|jjtjdƒ}|dkrdS|jƒ}t|tƒs`t|ƒ}t|dƒrP|j|j |ƒn||jt tjƒ<|S)zCReturns the existing ViewerPreferences as an overloaded dictionary.Nri) rgrEÚCDZVIEWER_PREFERENCESrKrFr2Úhasattrrlrir,)rCÚor>r>r?Úviewer_preferences>s  zPdfDocCommon.viewer_preferencescCsF|jr|jddS|jdkr*|j|jƒ|jdk s8t‚t|jƒSdS)a Calculate the number of pages in this PDF file. Returns: The number of pages of the parsed PDF file. Raises: PdfReadError: if file is encrypted and restrictions prevent this action. z/Pagesz/CountN)Ú is_encryptedrgÚflattened_pagesÚ_flattenÚ _readonlyÚAssertionErrorÚlen)rCr>r>r?Ú get_num_pagesOs   zPdfDocCommon.get_num_pages)Ú page_numberr:cCs2|jdkr|j|jƒ|jdk s(tdƒ‚|j|S)a> Retrieve a page by number from this PDF file. Most of the time ``.pages[page_number]`` is preferred. Args: page_number: The page number to retrieve (pages begin at zero) Returns: A :class:`PageObject` instance. Nz hint for mypy)ryrzr{r|)rCrr>r>r?Úget_pagees  zPdfDocCommon.get_pagecs^tt|jdƒ‰ttttttfdœ‡‡‡fdd„ ‰ˆˆdƒ\}}t|tƒsVtdƒ‚||fS)z¯ Retrieve the node and position within the /Kids containing the page. If page_number is greater than the number of pages, it returns the top node, -1. z/Pages)ÚnodeÚmir:csÎtt|jddƒƒ}|ddkr:ˆ|kr.|dfSd|dfSˆ||krb|ˆkrVˆd fSd||fSx^ttt|dƒƒD]H\}}tt|jƒƒ}ˆ||ƒ\}}|dk rº|dkr²||fS||fS|}qvWtdƒ‚dS) Nz/Countrz/Typez/Pagez/Kidsrz"Unexpectedly cannot find the node.éÿÿÿÿrƒ)r ÚintrEÚ enumerater"r&rKr!)r�r‚ÚmaÚidxÚkidÚnÚi)rÚrecursive_callÚtopr>r?r‹€s$    z6PdfDocCommon._get_page_in_node..recursive_callrZmypy) r r&rgr„r r r/rFr|)rCrr�r‡r>)rr‹rŒr?Ú_get_page_in_nodevs "zPdfDocCommon._get_page_in_nodecCs|jƒS)zu A read-only dictionary which maps names to :class:`Destinations` )Ú_get_named_destinations)rCr>r>r?Únamed_destinations�szPdfDocCommon.named_destinationscCs2tƒ}tj|jkrÖt|jtjtƒrÖtt|jtjƒ}|j}tj|kržt|tjtƒržtt|tjƒ}|j}tj|krˆtt|tjƒ}qÔtƒ}||t tjƒ<n6t |dƒrÔtƒ}|j |ƒ}||t tjƒ<||t tjƒ<nXt |dƒ�r.tƒ}|j |ƒ}||jt tjƒ<tƒ}|j |ƒ}||t tjƒ<||t tjƒ<|S)NÚ _add_object) r"ÚCAÚNAMESrgrFr&r riÚDESTSr,rur�)rCZ named_destÚnamesZ names_refZdestsZ dests_refr>r>r?Úget_named_dest_root¥s4      z PdfDocCommon.get_named_dest_root)ÚtreerGr:c CsÚ|dkrbi}|j}tj|kr.tt|tjƒ}n4tj|krbtt|tjƒ}tj|krbtt|tjƒ}|dkrn|Stj|kr¦x(tt |tjƒD]}|j |j ƒ|ƒqŠW�n0tj|k�rptt|tjƒ}d}x¦|t |ƒk�rltt ||j ƒƒ}|d7}t|t ƒsüqÈy||j ƒ}Wntk �r$PYnX|d7}t|tƒ�rNd|krÈ|d}nqÈ|j||ƒ} | dk rÈ| ||<qÈWnfxd|jƒD]X\} } | j ƒ} t| tƒ�r²d| k�rz| dj ƒ} n�qz|j| | ƒ} | dk �rz| || <�qzW|S)zü Retrieve the named destinations present in the document. Args: tree: retval: Returns: A dictionary which maps names to :class:`Destinations`. Nrrz/D)rgr‘r“r r1r’r&ÚPAÚKIDSr"rŽrKr}rdrFÚ IndexErrorÚ_build_destinationÚitems) rCr–rGÚcatalogr”rˆrŠrDÚvalueÚdestZk__Zv__Úvalr>r>r?rŽÈsX             z$PdfDocCommon._get_named_destinations)r–rGÚfileobjÚstackr:c sÔtjƒ}|jtjƒƒ|dkrPi}|j}g}tj|krLttt |tjƒ‰ndSˆdkr\|S|dk sht ‚dˆkr¨tt ˆdƒ}xP|D]}|j ƒ} |j | ||||ƒq„Wn(t‡fdd„|DƒƒrÐ|j ˆ||||ƒ|S)aÆ Extract field data if this PDF contains interactive form fields. The *tree*, *retval*, *stack* parameters are for recursive use. Args: tree: Current object to parse. retval: In-progress list of fields. fileobj: A file object (usually a text file) to write a report to on all interactive form fields found. stack: List of already parsed objects. Returns: A dictionary where each key is a field name, and each value is a :class:`Field` object. By default, the mapping name is used for keys. ``None`` if form data could not be located. Nz/Fieldsc3s|]}|ˆkVqdS)Nr>)Ú.0Úattr)r–r>r?ú =sz*PdfDocCommon.get_fields..)ÚFAZattributes_dictrnrrgrtZ ACRO_FORMr r r1r|r"rKÚ _build_fieldÚany) rCr–rGr r¡Úfield_attributesrœÚfieldsÚfÚfieldr>)r–r?Ú get_fieldss(   zPdfDocCommon.get_fields)Úparentr:cCs^d|krtt|dƒSd|krH|jtt|dƒƒdtt|jddƒƒStt|jddƒƒSdS)Nz/TMz/ParentÚ.z/TÚ)r rdÚ_get_qualified_field_namer&rE)rCr­r>r>r?r°Bs *z&PdfDocCommon._get_qualified_field_name)r«rGr r¨r¡r:c st‡fdd„dDƒƒrdS|jˆƒ}|r@|j|ˆ|ƒ|jdƒtˆƒ||<||jjƒ}|jtj dƒdkr†|t tj ƒ||t dƒ<|jtj dƒd krðd |krðt t |d d jƒƒƒ||t dƒ<d ||dkrî||t dƒjt d ƒƒnü|jtj dƒd k�rì|jtjd ƒtjj@d k�rìg}t |ƒ||t dƒ<xh|jtjiƒD]V} | jƒ} x2t | d d jƒƒD]} | |k�rj|j| ƒ�qjWt |ƒ||t dƒ<�qHW|jtjd ƒtjj@d k�rìd ||dk�rì||d||djd ƒ=|jˆ|||ƒdS)Nc3s|]}|ˆkVqdS)Nr>)r¢r£)r«r>r?r¤Xsz,PdfDocCommon._build_field..ú/Tú/TMÚ r¯z/Chz /_States_z/Btnz/APz/Nz/Offr)r±r²)Úallr°Ú _write_fieldÚwriter(rirKrEr¥ÚFTr,ZOptr"ÚlistÚkeysÚappendZFfZFfBitsZRadioÚKidsZ NoToggleToOffÚindexÚ _check_kids) rCr«rGr r¨r¡rDrkZstatesÚkÚsr>)r«r?r¦Ps8   "0 zPdfDocCommon._build_fieldcCsf||kr"t|j|ƒ›d�tƒdS|j|ƒtj|krbx*|tjD]}|jƒ}|j||||ƒqBWdS)Nz already parsed)rr°r`rºr—r˜rKr¬)rCr–rGr r¡rˆr>r>r?r½zs  zPdfDocCommon._check_kids)r r«r¨r:c Cstjƒ}|tjƒ}xø|D]ð}|tjtjfkr0q||}yº|tjkr~dddddœ}|||krð|j|›d|||›d�ƒnr|tjkrÖy||tj}Wn"t k r¼||tj }YnX|j|›d|›d�ƒn|j|›d||›d�ƒWqt k �rYqXqWdS)NZButtonZTextZChoiceÚ Signature)z/Btnz/Txz/Chz/Sigz: r³) r¥Ú attributesrr»ZAAr·r¶ZParentZTMÚKeyErrorÚT) rCr r«r¨Zfield_attributes_tupler£Ú attr_nameÚtypesÚnamer>r>r?rµ�s2       zPdfDocCommon._write_field)Úfull_qualified_namer:cCsŒttttftdœdd„}|jƒ}|dkr.iSi}xT|jƒD]H\}}|jdƒdkr<|rf|jdƒ||<q<|jdƒ||tt|dƒ|ƒ<qr?ú ÈszJPdfDocCommon.get_form_text_fields..indexed_key..é)rdÚsum)r¾r©r>)r¾r?Ú indexed_keyÁsz6PdfDocCommon.get_form_text_fields..indexed_keyNz/FTz/Txz/Vz/T)rdrrr¬r›rEr )rCrÇrÍZ formfieldsÚffr«r�r>r>r?Úget_form_text_fields²s "z!PdfDocCommon.get_form_text_fields)r«r:cs2tttdœ‡fdd„ ‰yttˆjjƒƒ‰Wn,tk rV}ztdƒ|‚WYdd}~XnXtˆˆdƒƒrntdƒ‚g}ˆj dd ƒd kr°d ˆkršˆd jƒg}n‡fd d „ˆj Dƒ}npˆj dfƒ}xb|D]Z‰ˆjƒ‰ˆj dd ƒd koädˆkrÂd ˆk�r|ˆd jƒg7}qÂ|‡fdd „ˆj Dƒ7}qÂW‡fdd „|DƒS)a… Provides list of pages where the field is called. Args: field: Field Object, PdfObject or IndirectObject referencing a Field Returns: List of pages: - Empty list: The field has no widgets attached (either hidden field or ancestor field). - Single page list: Page where the widget is present (most common). - Multi-page list: Field with multiple kids widgets (example: radio buttons, field repeated on multiple pages). )rkrDr:cs8||kr||Sd|kr0ˆtt|djƒƒ|ƒSdSdS)Nz/Parent)r r&rK)rkrD)Ú_get_inheritedr>r?rÐîs z._get_inheritedzfield type is invalidNz/FTzfield is not validz/Subtyper¯z/Widgetz/Pcs"g|]}ˆj|jddƒkr|‘qS)z/Annotsr¯)rirE)r¢Úp)r«r>r?rÊsz8PdfDocCommon.get_pages_showing_field..z/Kidsz/Tcs"g|]}ˆj|jddƒkr|‘qS)z/Annotsr¯)rirE)r¢rÑ)r¾r>r?rÊscs,g|]$}t|tƒr|nˆjˆj|jƒ‘qSr>)rFrÚpagesÚ_get_page_number_by_indirectri)r¢Úx)rCr>r?rÊs) r&rdrr rirKÚ ExceptionÚ ValueErrorr4rErÒ)rCr«ÚexcÚretZkidsr>)rÐr«r¾rCr?Úget_pages_showing_fieldØs0        z$PdfDocCommon.get_pages_showing_fieldcCs¾d|jkrdS|jd}t|tƒr*|jƒ}t|tƒrr>r?Úopen_destinations       (zPdfDocCommon.open_destination)ržr:cCs tdƒ‚dS)Nzno setter for open_destination)ÚNotImplementedError)rCržr>r>r?rá<scCs|jƒS)z© Read-only property for the outline present in the document (i.e., a collection of 'outline items' which are also known as 'bookmarks'). )Ú _get_outline)rCr>r>r?Úoutline@szPdfDocCommon.outline)r�rär:cCsÚ|dkrdg}|j}tj|krZtt|tjƒ}t|tƒr:|St|ƒ rZd|krZtt|dƒ}|jƒ|_ |dkrp|Sxd|j |ƒ}|rŠ|j |ƒd|krºg}|j tt|dƒ|ƒ|rº|j |ƒd|krÄPtt|dƒ}qrW|S)Nz/Firstz/Next) rgÚCOZOUTLINESr r&rFr-r4rŽÚ _namedDestsÚ_build_outline_itemrºrã)rCr�rärœÚlinesZ outline_objZ sub_outliner>r>r?rãIs2      zPdfDocCommon._get_outlinecCs(|j}tj|kr td|tjƒSdSdS)uN Read-only property for the list of threads. See §12.4.3 from the PDF 1.7 or 2.0 specification. It is an array of dictionaries with "/F" (the first bead in the thread) and "/I" (a thread information dictionary containing information about the thread, such as its title, author, and creation date) properties or None if there are no articles. Since PDF 2.0 it can also contain an indirect reference to a metadata stream containing information about the thread, such as its title, author, and creation date. r"N)rgråZTHREADSr )rCrœr>r>r?Úthreadsrs zPdfDocCommon.threadscCsdS)Nr>)rCrir>r>r?rÓˆsz)PdfDocCommon._get_page_number_by_indirect)rÝr:cCs |j|jƒS)a Retrieve page number of a given PageObject. Args: page: The page to get page number. Should be an instance of :class:`PageObject` Returns: The page number or None if page is not found )rÓri)rCrÝr>r>r?Úget_page_numberŽs zPdfDocCommon.get_page_number)Ú destinationr:cCs |j|jƒS)zÜ Retrieve page number of a given Destination object. Args: destination: The destination to get page number. Returns: The page number or None if page is not found )rÓrÝ)rCrër>r>r?Úget_destination_page_number›s z(PdfDocCommon.get_destination_page_number)rLrßr:c CsÜd\}}t|ttfƒs4t|tƒr,t|ƒdks4|dkrJtƒ}t||tjƒƒS|dd…\}}|dd…}yt||t||d�ƒStk rÖt d|›d|›�t ƒ|j r¨‚|j dj }|dkrÂtƒn|}t||tjƒƒSXdS)NrrË)Zfit_typeZfit_argszUnknown destination: ú )NN)rFr-rdr"r}r%r)ràr rr`ÚstrictrÒri)rCrLrßrÝrÞÚtmprir>r>r?rš§s"   zPdfDocCommon._build_destination)r�r:cCs d\}}}ytd|dƒ}Wn,tk rH|jr@td|›�ƒ‚d}YnXd|kr„tt|dƒ}tt|tjƒ}|dkr®|tj}n*d|kr®|d}t |tƒr®d|kr®|d}t |t ƒrÆ|j ||ƒ}n˜t |t ƒ�ry|j ||j |jƒ}Wn"tk �r |j |dƒ}YnXnN|dk�r(|j ||ƒ}n6|j�r@td |›�ƒ‚ntd |›d �tƒ|j |dƒ}|�rÜd |k�rŒt d d„|d Dƒƒ|td ƒ<d|k�r¦|d|tdƒ<d|k�rÀ|d|tdƒ<t|jddƒdkƒ|tdƒ<||_y |j|_Wntk �rYnX|S)Nrdz/Titlez(Outline Entry Missing /Title attribute: r¯z/Az/GoToz/Destz/DzUnexpected destination zRemoved unexpected destination z from destinationz/Ccss|]}t|ƒVqdS)N)r*)r¢Úcr>r>r?r¤þsz3PdfDocCommon._build_outline_item..z/Fz/Countrz /%is_open%)NNN)r rÂrîr r&r,rÚSÚDrFr"ršrdræZ dest_arrayrr`r#rEr�riÚAttributeError)rCr�ržrLZ outline_itemÚactionZ action_typer>r>r?rçÇs^            z PdfDocCommon._build_outline_itemcCst|j|jƒS)aW Property that emulates a list of :class:`PageObject`. This property allows to get a page or a range of pages. Note: For PdfWriter only: Provides the capability to remove a page/range of page from the list (using the del operator). Remember: Only the page entry is removed, as the objects beneath can be used elsewhere. A solution to completely remove them - if they are not used anywhere - is to write to a buffer/temporary file and then load it into a new PdfWriter. )rr~r€)rCr>r>r?rÒszPdfDocCommon.pagescs‡fdd„ttˆjƒƒDƒS)z² A list of labels for the pages in this document. This property is read-only. The labels are in the order that the pages appear in the document. csg|]}tˆ|ƒ‘qSr>)Úpage_index2page_label)r¢rŠ)rCr>r?rÊ+sz,PdfDocCommon.page_labels..)Úranger}rÒ)rCr>)rCr?Ú page_labels#szPdfDocCommon.page_labelsc Cs,ytt|jtjƒStk r&dSXdS)aï Get the page layout currently being used. .. list-table:: Valid ``layout`` values :widths: 50 200 * - /NoLayout - Layout explicitly not specified * - /SinglePage - Show one page at a time * - /OneColumn - Show one column at a time * - /TwoColumnLeft - Show pages in two columns, odd-numbered pages on the left * - /TwoColumnRight - Show pages in two columns, odd-numbered pages on the right * - /TwoPageLeft - Show two pages at a time, odd-numbered pages on the left * - /TwoPageRight - Show two pages at a time, odd-numbered pages on the right N)r r,rgrtZ PAGE_LAYOUTrÂ)rCr>r>r?Ú page_layout-szPdfDocCommon.page_layoutc Cs$y |jdStk rdSXdS)a2 Get the page mode currently being used. .. list-table:: Valid ``mode`` values :widths: 50 200 * - /UseNone - Do not show outline or thumbnails panels * - /UseOutlines - Show outline (aka bookmarks) panel * - /UseThumbs - Show page thumbnails panel * - /FullScreen - Fullscreen view * - /UseOC - Show Optional Content Group (OCG) panel * - /UseAttachments - Show attachments panel z /PageModeN)rgrÂ)rCr>r>r?Ú page_modeIs zPdfDocCommon.page_mode)Ú list_onlyrÒÚinheritrir:c Cs�ttjƒttjƒttjƒttjƒf}|dkr0i}|dkr^|j}|djƒ}t|t ƒsXt ‚g|_ t j |krztt|t j ƒ}nt j|krŠd}nd}|dk�r.x |D]}||krž||||<qžWxÐtt|t jƒD]\} i} t| tƒræ| | d<| jƒ} | rÌy|j|| |f| ŽWqÌtk �r&tdƒ‚YqÌXqÌWn^|dk�rŒx,t|jƒƒD]\} } | |k�rF| || <�qFWt||ƒ}|�s€|j|ƒ|j j|ƒdS)a  Prepare the document pages to ease searching Args: list_only: Will only list the pages within _flatten_pages. pages: inherit: indirect_reference: Used recursively to flatten the /Pages object. Nz/Pagesz/Pageriz7Maximum recursion depth reached during page flattening.)r,ÚPGZ RESOURCESZMEDIABOXZCROPBOXZROTATErgrKrFr&r|ryr—ZTYPEr rdr˜r"r+rzÚRecursionErrorr r¸r›rrnrº)rCrúrÒrûriZinheritable_page_attributesrœÚtr£rÝZaddtrkZattr_inr�Zpage_objr>r>r?rzcsN           zPdfDocCommon._flatten)rÝÚcleanr:c Csê|jdkr|j|jƒ|jdk s$t‚t|tƒrR|jƒ}t|tƒsNtdt ƒdS|}t|t ƒsŒy|jj |ƒ}Wnt k rŠtdt ƒdSXd|ko¤t |jƒkns¸tdt ƒdS|j|j}|j|=|ræ|dk ræ|j|tƒƒdS)a Remove page from pages list. Args: page: * :class:`int`: Page number to be removed. * :class:`~pypdf._page.PageObject`: page to be removed. If the page appears many times only the first one will be removed. * :class:`~pypdf.generic.IndirectObject`: Reference to page to be removed. clean: replace PageObject with NullObject to prevent annotations or destinations to reference a detached page. Nz(IndirectObject is not referencing a pagezCannot find page in pagesrzPage number is out of range)ryrzr{r|rFr+rKrrr`r„r¼rÖr}rÒrirlr-)rCrÝrÿrÑÚindr>r>r?Ú remove_page©s,          zPdfDocCommon.remove_page)ÚnumÚgenr:cCst|||ƒjƒS)a/ Used to ease development. This is equivalent to generic.IndirectObject(num,gen,self).get_object() Args: num: The object number of the indirect object. gen: The generation number of the indirect object. Returns: A PdfObject )r+rK)rCrrr>r>r?Ú_get_indirect_objectÔs z!PdfDocCommon._get_indirect_object)Úpermissions_coder:c sJtdddd�tjtjtjtjtjtjtjtj dœ}‡fdd„|j ƒDƒS)z>Take the permissions as an integer, return the allowed access.Údecode_permissionsÚuser_access_permissionsz5.0.0)Zold_nameÚnew_nameZ removed_in)ÚprintÚmodifyÚcopyÚ annotationsZformsZ accessabilityZassembleZprint_high_qualitycsi|]\}}ˆ|@dk|“qS)rr>)r¢rDÚflag)rr>r?ú ùsz3PdfDocCommon.decode_permissions..) rrZPRINTZMODIFYZEXTRACTZ ADD_OR_MODIFYZFILL_FORM_FIELDSZEXTRACT_TEXT_AND_GRAPHICSZ ASSEMBLE_DOCZPRINT_TO_REPRESENTATIONr›)rCrZpermissions_mappingr>)rr?rãs  zPdfDocCommon.decode_permissionscCs|jdkrdSt|jjƒS)zWGet the user access permissions for encrypted documents. Returns None if not encrypted.N)Ú _encryptionrÚP)rCr>r>r?rþs z$PdfDocCommon.user_access_permissionscCsdS)zè Read-only boolean property showing whether this PDF file is encrypted. Note that this property, if true, will remain true even after the :meth:`decrypt()` method is called. Nr>)rCr>r>r?rxs zPdfDocCommon.is_encryptedc Cs¢d}i}|j}d|ks |d r$dStt|dƒ}d|kržtt|dƒ}t|ƒ}xL|D]D}|}t|ƒ}t|tƒrVttt |j ƒƒ}|rVt j |j ƒ} | ||<qVW|S)Nz /AcroFormz/XFA)rgr r1r"ÚiterÚnextrFr+r r'rKÚzlibÚ decompressÚ_data) rCr–rGrœr©rŠrªÚtagr«Úesr>r>r?Úxfas$    zPdfDocCommon.xfacst‡fdd„ˆjƒDƒƒS)Ncsi|]}ˆj|f|“qSr>)Ú_get_attachment_list)r¢rÆ)rCr>r?r+sz,PdfDocCommon.attachments..)ÚLazyDictÚ_list_attachments)rCr>)rCr?Ú attachments(s zPdfDocCommon.attachmentscCsT|j}y&tttttt|dƒdƒdƒ}Wntk r@gSXdd„|Dƒ}|S)zv Retrieves the list of filenames of file attachments. Returns: list of filenames z/Namesz/EmbeddedFilescSsg|]}t|tƒr|‘qSr>)rFrd)r¢rªr>r>r?rÊDsz2PdfDocCommon._list_attachments..)rgr r"r&rÂ)rCrœÚ filenamesZattachments_namesr>r>r?r1s zPdfDocCommon._list_attachments)rÆr:cCs"|j|ƒ|}t|tƒr|S|gS)N)Ú_get_attachmentsrFr¸)rCrÆÚoutr>r>r?rGs z!PdfDocCommon._get_attachment_list)Úfilenamer:c Csä|j}y&tttttt|dƒdƒdƒ}Wntk r@iSXi}x˜tt|ƒƒD]ˆ}||}t|tƒrT|dk r|||kr|qT|}||dj ƒ}|ddj ƒ} ||krÔt||t ƒsÄ||g||<||j | ƒqT| ||<qTW|S)a’ Retrieves all or selected file attachments of the PDF as a dictionary of file names and the file data as a bytestring. Args: filename: If filename is None, then a dictionary of all attachments will be returned, where the key is the filename and the value is the content. Otherwise, a dictionary with just a single key - the filename - and its content will be returned. Returns: dictionary of filename -> Union[bytestring or List[ByteString]] If the filename exists multiple times a list of the different versions will be provided. z/Namesz/EmbeddedFilesNrz/EFz/F) rgr r"r&rÂrör}rFrdrKÚget_datar¸rº) rCr rœrrrŠrªrÆZf_dictZf_datar>r>r?rMs2   zPdfDocCommon._get_attachments)NN)NN)NNNN)F)NN)FNNN)F)N)Xr`rarbrcrîÚboolrr rr{rerr&rgrdrhr r„r+r/rKrlrmrAror7rprrrrsr2rwryrrr~r€r r�r�r"r•r1rŽr¬r°r¦r½rµrÏr(rÙr%r0r$ráÚsetterr5rärãrér-rÓrêrìr.ršrçrÒr÷rør6rùrzrrrrrrxrr rÚrrrrr>r>r>r?rfõsà    $%G&+  %  %' D ' K $C' rfc@s\eZdZeeddœdd„Zeedœdd„Zeedœd d „Ze dœd d „Z edœd d„Z dS)rN)ÚargsÚkwr:cOst||Ž|_dS)N)ÚdictÚ _raw_dict)rCr$r%r>r>r?rB~szLazyDict.__init__)rDr:cCs|jj|ƒ\}}||ƒS)N)r'Ú __getitem__)rCrDÚfuncÚargr>r>r?r(�szLazyDict.__getitem__)r:cCs t|jƒS)N)rr')rCr>r>r?Ú__iter__…szLazyDict.__iter__cCs t|jƒS)N)r}r')rCr>r>r?Ú__len__ˆszLazyDict.__len__cCsdt|jƒƒ›d�S)NzLazyDict(keys=ú))r¸r¹)rCr>r>r?Ú__str__‹szLazyDict.__str__) r`rarbrrBrdr(rr+r„r,r.r>r>r>r?r}s r)Pr<rÚabcrrÚtypingrrrrrr r r r r rrZ_pagerrZ _page_labelsrrõÚ_utilsrrrÚ constantsrr‘rrtrrrrrårrIrr¥rrürr—Úerrorsr r!Zgenericr"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4rÅr5r6Úxmpr7rÚr„r@rArfrr>r>r>r?ÚsD  0         T "