Warning: session_start(): Session cannot be started after headers have already been sent in /home/tvrreohg/public_html/manga.php on line 13
3 ©«jîtã@sdddlZddlmZmZmZddlmZddlmZddl m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZdd lmZdd lmZmZmZmZdd lmZdd l m!Z!dd l m"Z#ddl m$Z$m%Z%ddl&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1ddl2m3Z3m4Z4ddlm5Z5m6Z6m7Z7m8Z8m9Z9dZ:Gdd„dƒZ;Gdd„dƒZ„ƒZ2ee1dd?œd@dA„Z3edd�d^ee1e e,e-ddBœdCdD„ƒZ4edd;�d_eeefe e)e eedEœdFdG„ƒZ5edd;�d`eeefe e)e eedEœdHdI„ƒZ6daddKœee eede.e7fe ee8e8e8feee9e:e ee7dLœ dMdN„Z;dbeeede.e7fe ee8e8e8feee9e:e7dOœ dPdQ„Zddee ee eddWœdXdY„Z?dS)eÚ PdfMergeraI Initialize a ``PdfMerger`` object. ``PdfMerger`` merges multiple PDFs into a single PDF. It can concatenate, slice, insert, or any combination of the above. See the functions :meth:`merge()` (or :meth:`append()`) and :meth:`write()` for usage information. :param bool strict: Determines whether user should be warned of all problems and also causes some correctable problems to be fatal. Defaults to ``False``. :param fileobj: Output file. Can be a filename or any kind of file-like object. Úoutline)Z bookmarksFÚN)ÚstrictÚfileobjr3cCs6g|_g|_tƒ|_g|_g|_d|_||_||_dS)Nr) ÚinputsÚpagesrÚoutputr?Ú named_destsÚid_countrBrA)r5rArBr6r6r7r8gszPdfMerger.__init__)r3cCs|S)Nr6)r5r6r6r7Ú __enter__tszPdfMerger.__enter__)Úexc_typeÚexcÚ tracebackr3cCs|jr|j|jƒ|jƒdS)z*Write to the fileobj and close the merger.N)rBÚwriteÚclose)r5rIrJrKr6r6r7Ú__exit__xs zPdfMerger.__exit__Ú outline_itemÚimport_outline)ÚbookmarkZimport_bookmarksT)Ú page_numberrBrOrDrPÚpositionr3cCsà|dk r>|dkr6|}d}d}tj|›d|›d�d�ntdƒ‚|dkrNtdƒ‚|dkr^td ƒ‚|j|ƒ\} } t| |jd �} |jj| | fƒ| dk r˜| | _|dkr°d t | j ƒf}n:t |t ƒrÌ|j t | j ƒƒ}nt |tƒrØnt |tƒsêtd ƒ‚g} g} |�r | j} |j| | |ƒ} |�rBtt|ƒt|jƒttjƒƒ}|j|| g7_n|j| 7_| j}|j| ||ƒ}|j|7_xFt|ŽD]:}| j |}|j}|jd 7_t|| |ƒ}| j|ƒ�q|W|j| ƒ|j | ƒ| |j ||…<dS)a¾ Merge the pages from the given file into the output file at the specified page number. :param int page_number: The *page number* to insert this file. File will be inserted after the given number. :param fileobj: A File Object or an object that supports the standard read and seek methods similar to a File Object. Could also be a string representing a path to a PDF file. :param str outline_item: Optionally, you may specify an outline item (previously referred to as a 'bookmark') to be applied at the beginning of the included file by supplying the text of the outline item. :param pages: can be a :class:`PageRange` or a ``(start, stop[, step])`` tuple to merge only the specified range of pages from the source document into the output document. Can also be a list of pages to merge. :param bool import_outline: You may prevent the source document's outline (collection of outline items, previously referred to as 'bookmarks') from being imported by specifying this as ``False``. NrSrRz# is deprecated as an argument. Use z instead)ÚmessagezCThe argument position of merge is deprecated. Use page_number only.zpage_number may not be Nonezfileobj may not be None)rArz0"pages" must be a tuple of (start, stop[, step])r)!ÚwarningsÚwarnÚ ValueErrorÚ_create_streamrrArCÚappendÚ _encryptionÚlenrDÚ isinstancer(ÚindicesÚlistÚtupleÚ TypeErrorr?Ú _trim_outliner%r&r$rGr"rZFITZnamed_destinationsÚ _trim_destsrFÚranger/Ú_associate_dests_to_pagesÚ!_associate_outline_items_to_pages)r5rRrBrOrDrPrSÚold_termÚnew_termÚstreamÚencryption_objÚreaderZsrcpagesr?Zoutline_item_typÚdestsZ trimmed_destsÚiÚpager2Úmpr6r6r7Úmergeƒsd#        zPdfMerger.merge)rBr3cCs¦d}t|ttfƒrt|dƒ}n€t|tƒrf|jr4|j}|jjƒ}|jjdƒt |jj ƒƒ}|jj|ƒn8t |dƒr–t |dƒr–|jdƒ|j ƒ}t |ƒ}nt dƒ‚||fS)NÚrbrÚseekÚreadzÝPdfMerger.merge requires an object that PdfReader can parse. Typically, that is a Path or a string representing a Path, a file object, or an object implementing .seek and .read. Passing a PdfReader directly works as well.) r\ÚstrrrrrZrhÚtellrqrrrÚhasattrÚNotImplementedError)r5rBrirhZ orig_tellZ filecontentr6r6r7rX÷s"       zPdfMerger._create_stream)rBrOrDrPr3cCs|jt|jƒ||||ƒdS)a‡ Identical to the :meth:`merge()` method, but assumes you want to concatenate all pages onto the end of the file instead of specifying a position. :param fileobj: A File Object or an object that supports the standard read and seek methods similar to a File Object. Could also be a string representing a path to a PDF file. :param str outline_item: Optionally, you may specify an outline item (previously referred to as a 'bookmark') to be applied at the beginning of the included file by supplying the text of the outline item. :param pages: can be a :class:`PageRange` or a ``(start, stop[, step])`` tuple to merge only the specified range of pages from the source document into the output document. Can also be a list of pages to append. :param bool import_outline: You may prevent the source document's outline (collection of outline items, previously referred to as 'bookmarks') from being imported by specifying this as ``False``. N)ror[rD)r5rBrOrDrPr6r6r7rYs!zPdfMerger.appendcCs–|jdkrttƒ‚xR|jD]H}|jj|jƒtttt f|jj j ƒƒ}|jj |t jdj ƒƒ|_qW|jƒ|jƒ|jj|ƒ\}}|r’|jƒdS)z´ Write all data that has been merged to the given output file. :param fileobj: Output file. Can be a filename or any kind of file-like object. Nréÿÿÿÿ)rEÚ RuntimeErrorÚERR_CLOSED_WRITERrDZadd_pager0rrrsrZ_pagesÚ get_objectZ get_referenceÚPAZKIDSr4Ú _write_destsÚ_write_outlinerLrM)r5rBrmZ pages_objZmy_fileZ ret_fileobjr6r6r7rL=s  zPdfMerger.writecCs2g|_x|jD]\}}|jƒqWg|_d|_dS)zHShut all file descriptors (input and output) and clear all memory usage.N)rDrCrMrE)r5ÚfoÚ_readerr6r6r7rM]s  zPdfMerger.close)Úinfosr3cCs"|jdkrttƒ‚|jj|ƒdS)zá Add custom metadata to the output. :param dict infos: a Python dictionary where each key is a field and each value is your new metadata. Example: ``{u'/Title': u'My title'}`` N)rErxryÚ add_metadata)r5r€r6r6r7r�fs zPdfMerger.add_metadatacCstddƒ|j|ƒdS)zW .. deprecated:: 1.28.0 Use :meth:`add_metadata` instead. Ú addMetadatar�N)rr�)r5r€r6r6r7r‚rs zPdfMerger.addMetadata)Úlayoutr3cCstddƒ|j|ƒdS)zZ .. deprecated:: 1.28.0 Use :meth:`set_page_layout` instead. Ú setPageLayoutÚset_page_layoutN)rr…)r5rƒr6r6r7r„{s zPdfMerger.setPageLayoutcCs"|jdkrttƒ‚|jj|ƒdS)a Set the page layout. :param str layout: The page layout to be used .. list-table:: Valid ``layout`` arguments :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)rErxryZ_set_page_layout)r5rƒr6r6r7r…„s zPdfMerger.set_page_layout)Úmoder3cCstddƒ|j|ƒdS)zX .. deprecated:: 1.28.0 Use :meth:`set_page_mode` instead. Ú setPageModeÚ set_page_modeN)rrˆ)r5r†r6r6r7r‡ s zPdfMerger.setPageModecCs"|jdkrttƒ‚|jj|ƒdS)aP Set the page mode. :param str mode: The page mode to use. .. list-table:: Valid ``mode`` arguments :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 N)rErxryrˆ)r5r†r6r6r7rˆ©s zPdfMerger.set_page_mode)ÚpdfrkrDr3c Cs˜g}t|tƒr|n tt|Žƒ}xt|jƒD]h\}}x^|D]V}|j|jƒ|djƒkr6|djƒ|tdƒ<t|ƒt|dƒks€t‚|j |ƒPq6Wq(W|S)zHRemove named destinations that are not a part of the specified page set.z/Pagez/Title) r\r^rcÚitemsrDrzr"rÚAssertionErrorrY) r5r‰rkrDZ new_destsÚlstÚkeyÚobjÚjr6r6r7rbÃs   zPdfMerger._trim_dests)r‰r?rDr3c CsØg}d}t|tƒr|n tt|Žƒ}x°t|ƒD]¤\}}t|tƒrr|j|||ƒ} | rÐ|sf|j||dƒ|j| ƒq,d}xX|D]P} |ddkrŽq||j| jƒ|djƒkr||djƒ|tdƒ<|j|ƒd}Pq|Wq,W|S)zJRemove outline item entries that are not a part of the specified page set.TrFz/PageN) r\r^rcÚ enumeraterarYrDrzr") r5r‰r?rDZ new_outlineZprev_header_addedrŒrlrOÚsubr�r6r6r7raÕs*      zPdfMerger._trim_outlinecCs||jdkrttƒ‚xd|jD]Z}d}d|kr`x4t|jƒD]&\}}|j|dkr6|j|tdƒ<Pq6W|dk r|jj |ƒqWdS)Nz/Page) rErxryrFr�rDr2r4r"Zadd_named_destination_object)r5Ú named_destÚpagenormr6r6r7r|ôs  zPdfMerger._write_dests)r?Úparentr3cCsÀ|jdkrttƒ‚|dkr |j}|dk s0tdƒ‚d}x†|D]~}t|tƒrV|j||ƒq:d}d|kr–x2t|j ƒD]$\}}|j |dkrn|j ||ƒPqnW|dk r:|d=|d=|jj ||ƒ}q:WdS)Nz hint for mypyz/Pagez/Type) rErxryr?r‹r\r^r}r�rDr2Ú_write_outline_item_on_pageZadd_outline_item_dict)r5r?r”Z last_addedrOZpage_normr6r6r7r}s&      zPdfMerger._write_outline)rQ)rOrmr3cCsútt|dƒ}t|jƒt|ƒg}tjtjftj tjftj tj ftj tj ftj tj tjdftjtj tjtjtjfi}xV|j|tƒƒD]D}||kr²t||tƒ r²|jt||ƒƒn|jtdƒƒ||=q‚Wtttjƒtdƒttjƒt|ƒiƒ|tdƒ<dS)Nz/Typez/Zoomrz/GoToz/A)rrsr$r2r"rÚFIT_HrZTOPZFIT_BHZFIT_VÚLEFTZFIT_BVZXYZZFIT_RZBOTTOMÚRIGHTÚgetr_r\r#rYr rrÚSÚDr)r5rOrmZoi_typeÚargsZ fit2arg_keysZarg_keyr6r6r7r•s*       z%PdfMerger._write_outline_item_on_page)rDr3cCs~xx|jD]n}d}|d}t|tƒr$qx$|D]}|jƒ|jjƒkr*|j}q*W|dkrftd|d›d�ƒ‚t|ƒ|tdƒ<qWdS)Nz/PagezUnresolved named destination 'z/Titleú')rFr\r$rzr0r2rWr")r5rDr’r“Únprmr6r6r7rdAs    z#PdfMerger._associate_dests_to_pages)rDr?r3cCsž|dkr|j}|dk stdƒ‚xz|D]r}t|tƒr@|j||ƒq$d}|d}t|tƒrXq$x$|D]}|jƒ|jjƒkr^|j}q^W|dk r$t|ƒ|t dƒ<q$WdS)Nz hint for mypyz/Page) r?r‹r\r^rer$rzr0r2r")r5rDr?rOr“Zoutline_item_pageÚpr6r6r7reSs       z+PdfMerger._associate_outline_items_to_pages)rOÚrootr3cCsv|dkr|j}xbt|ƒD]V\}}t|tƒrF|j||ƒ}|rn|g|Sq||kshttttf|dƒ|kr|gSqWdS)Nz/Title)r?r�r\r^Úfind_outline_itemrrr)r5rOr rlZoi_enumÚresr6r6r7r¡ls    zPdfMerger.find_outline_itemcCs |j||ƒS)zZ .. deprecated:: 2.9.0 Use :meth:`find_outline_item` instead. )r¡)r5rOr r6r6r7Ú find_bookmark…s zPdfMerger.find_bookmarkú/Fit)Úpagenum) ÚtitlerRr”ÚcolorÚboldÚitalicÚfitrœr¥r3c Gs†|dk r|dk rtdƒ‚|dk rDd} d} tj| ›d| ›d�d�|}|dkrTtdƒ‚|j} | dkrjttƒ‚| j|||||||f| žŽS) a¦ Add an outline item (commonly referred to as a "Bookmark") to this PDF file. :param str title: Title to use for this outline item. :param int page_number: Page number this outline item will point to. :param parent: A reference to a parent outline item to create nested outline items. :param tuple color: Color of the outline item's font as a red, green, blue tuple from 0.0 to 1.0 :param bool bold: Outline item font is bold :param bool italic: Outline item font is italic :param str fit: The fit of the destination page. See :meth:`add_link()` for details. NzMThe argument pagenum of add_outline_item is deprecated. Use page_number only.r¥rRz# is deprecated as an argument. Use z instead)rTzpage_number may not be None)rWrUrVrErxryÚadd_outline_item) r5r¦rRr”r§r¨r©rªr¥rœrfrgÚwriterr6r6r7r«‘s zPdfMerger.add_outline_item) r¦r¥r”r§r¨r©rªrœr3c Gs&tddƒ|j|||||||f|žŽS)zZ .. deprecated:: 1.28.0 Use :meth:`add_outline_item` instead. Ú addBookmarkr«)rr«) r5r¦r¥r”r§r¨r©rªrœr6r6r7r­Ás zPdfMerger.addBookmarkc Gs&tddƒ|j|||||||f|žŽS)zY .. deprecated:: 2.9.0 Use :meth:`add_outline_item` instead. r­r«)rr«) r5r¦r¥r”r§r¨r©rªrœr6r6r7Ú add_bookmarkÕs zPdfMerger.add_bookmark)r¦r¥r3cCstddƒ|j||ƒS)z_ .. deprecated:: 1.28.0 Use :meth:`add_named_destination` instead. ÚaddNamedDestinationÚadd_named_destination)rr°)r5r¦r¥r6r6r7r¯és zPdfMerger.addNamedDestination)r¦rRr¥r3cCs„|dk r|dk rtdƒ‚|dk rDd}d}tj|›d|›d�d�|}|dkrTtdƒ‚tt|ƒt|ƒttjƒtd ƒƒ}|j j |ƒdS) z¢ Add a destination to the output. :param str title: Title to use :param int page_number: Page number this destination points at. NzRThe argument pagenum of add_named_destination is deprecated. Use page_number only.r¥rRz# is deprecated as an argument. Use z instead)rTzpage_number may not be Nonei:) rWrUrVrr&r$r"rr–rFrY)r5r¦rRr¥rfrgÚdestr6r6r7r°ñs"  zPdfMerger.add_named_destination)Fr@)NNNNTN)NNT)NN)N)N)N)NNNFFr¤)NNFFr¤)NNFFr¤)NN)@r9r:r;r<rÚboolrrrr8rHr r Ú BaseExceptionrrNr=rrsr)ror rrrXr(r rYrLrMrrr�r‚r+r„r…r-r‡rˆrbr,rar|r r%r'r}rr/r•rdrer¡r£r!Úfloatr*r.r«r­r®r¯r°r6r6r6r7r>Vs¨   (l ! <      ""   8)((  r>cs&eZdZeeddœ‡fdd„ Z‡ZS)Ú PdfFileMergerN)rœÚkwargsr3cs8tddƒd|kr&t|ƒdkr&d|d<tƒj||ŽdS)Nrµr>rArT)rr[Úsuperr8)r5rœr¶)Ú __class__r6r7r8s zPdfFileMerger.__init__)r9r:r;rr8Ú __classcell__r6r6)r¸r7rµsrµ)>rUÚiorrrZpathlibrÚtypesrÚtypingrrr r r r r rrrZrZ_pagerrrÚ_utilsrrrrZ_writerrÚ constantsrrr{rrZgenericrrrr r!r"r#r$r%r&r'Z pageranger(r)r*r+r,r-r.ryr/r>rµr6r6r6r7Ús0  ,      4  D