
    %h7                    :   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
Jr  S SKJrJrJr  S SKJr  S SKJr  S SKJrJrJrJrJrJrJrJrJrJrJrJ r J!r!  SSK"J#r#  SS	K$J%r%J&r&  SS
K'J(r(  SSK)J*r*J+r+J,r,  SSK-J.r.J/r/J0r0J1r1J2r2J3r3J4r4J5r5  SSK6J7r7  SSK6J8r9  SSK6J:r:  SSK6J;r<  SSK6J=r>  SSK6J?r?J@r@JArAJBrBJCrC  SSK6JDrE  SSK6JFrG  SSK6JHrI  SSK6JJrK  SSK6JLrLJMrM  SSKNJOrOJPrPJQrQJRrRJSrSJTrTJUrUJVrVJWrWJXrXJYrYJZrZJ[r[J\r\J]r]J^r^J_r_J`r`JaraJbrbJcrcJdrd  SSKeJfrfJgrg  SSKJhrhJiriJjrjJkrkJlrlJmrmJnrn  \R                  " \p5      rq\@" S 5      rr\M" S5      rs " S S5      rtS\ \\u\4   \u\v\\   4   S\^4S  jrwS!\ S\Z4   S"\uS#\ \\x\x\x4   \uS4   S$\yS%\yS\b4S& jrz " S' S(\t5      r{g))    N)md5)BytesIOFileIOIOBase)Path)TracebackType)IOAnyCallableDequeDictIterableListOptionalPatternTupleTypeUnioncast   )
Encryption)
PageObject_VirtualList)	PdfReader)_alg33_alg34_alg35)StrByteType
StreamType_get_max_pdf_version_headerb_deprecate_with_replacementdeprecation_bookmarkdeprecation_with_replacementlogger_warning)AnnotationDictionaryAttributes)CatalogAttributes)CatalogDictionary)Core)EncryptionDictAttributes)FieldDictionaryAttributes	FieldFlag"FileSpecificationDictionaryEntriesGoToActionArgumentsInteractiveFormDictEntries)PageAttributes)PagesAttributes)StreamAttributes)TrailerKeys)TypFitArgumentsUserAccessPermissions)PAGE_FITAnnotationBuilderArrayObjectBooleanObjectByteStringObjectContentStreamDecodedStreamObjectDestinationDictionaryObjectFitFloatObjectIndirectObject
NameObject
NullObjectNumberObject	PdfObjectRectangleObjectStreamObjectTextStringObject
TreeObjectcreate_string_object
hex_to_rgb)	PageRangePageRangeSpec)BorderArrayTypeFitType
LayoutTypeOutlineItemTypeOutlineTypePagemodeTypeZoomArgTypeic                      \ rS rSrSrSS\SS4S jjrSS jrS\\	\
      S	\\
   S
\\   SS4S jr\S\4S j5       r\R                   S\SS4S j5       rS\S\4S jr  SS\S\\4   S\\   S\4S jjrS\\\4   S\4S jr SS\S\\\/S4   S\\   S\4S jjrSS jr SS\S\\   S\4S jjr SS\S\\   S\4S jjr   SS\S\S\\   S\4S jjr!  SS\S\S\\   S\4S jjr" SS\\   S \\   S\4S! jjr#S \S\4S" jr$S\4S# jr%S\4S$ jr&\S\'\   4S% j5       r( SS&\\)   S'\\)   S\4S( jjr* SS&\\)   S'\\)   S\4S) jjr+   SS&\\,RZ                     S'\\,RZ                     S\S\4S* jjr.   SS&\\,RZ                     S'\\,RZ                     S\S\4S+ jjr/\S\S\0\1\24   4S, j5       r3\3R                   S-\S\\0\4   SS4S. j5       r3S/\SS4S0 jr4S/\SS4S1 jr5S2\S3\\\4   SS4S4 jr6S5\S6\\\4   SS4S7 jr7 SS8\8S9\\\/S4      SS4S: jjr9 SS8\8S9\\\/S4      SS4S; jjr:\;4S\S<\<\\4   S=\=SS4S> jjr>\;4S\S<\<\\4   S=\=SS4S? jjr?S8\8SS4S@ jr@S8\8SS4SA jrA SS8\8S9\\\/S4      SS4SB jjrB SS8\8S9\\\/S4      SS4SC jjrCSSSD\DSS4SE\\   SF\\   SG\ESH\FSI\\   SJ\\   SS4SK jjrGSL\HSS4SM jrISL\\J\4   S\K\E\L4   4SN jrMSL\HS\'\   4SO jrNSL\HSP\'\   S\4SQ jrOSL\HSS4SR jrPSS\<\\4   SS4ST jrQSS\<\\4   SS4SU jrRSV\\S\T\U\V\\W\\X\1\Y4
   SS4SW jrZS3\S\4SX jr[S\S\4SY jr\S\S\4SZ jr]S\^4S[ jr_S\S4S\ jr`\S\S4S] j5       raS\^4S^ jrbS\S4S_ jrcS\S4S` jrd    SSa\S\\^4   Sb\S\^\4   Sc\S\^\4   S-\S\\^4   S\4
Sd jjre SS-\\\^4   Sb\S\^\4   S\4Se jjrf SS-\Sb\\^   S\4Sf jjrg\h" SgSh9  SSg\iSb\S\^\4   Sc\S\^\4   S\4Si jj5       rj\h" SgSh9 SSg\iSb\\^   S\4Sj jj5       rk\h" SgSh9 SSg\iSb\\^   S\4Sk jj5       rlSSSSlSl\mS4Sm\S\S\\\4   Sb\S\^\4   Sc\S\^\4   Sn\\\K\)\)\)4   \4      So\ESp\ESq\nSr\\   S\4Ss jjro     SSm\Sr\Sb\S\^\4   Sn\\K\)\)\)4      So\ESp\ESq\pSt\qS\4Su jjrr     SSm\Sr\Sb\S\^\4   Sn\\K\)\)\)4      So\ESp\ESq\pSt\qS\4Sv jjrsSSw jrtSm\1Sx\\\S4   SS4Sy jru  SSa\\   S-\\   S\4Sz jjrvS-\0S\4S{ jrw  SSm\S\\   Sr\\   S\4S| jjrxSm\Sr\S\4S} jrySS~ jrzSS jr{SS\ESS4S jjr| SS\ESS4S jjr}SS\ESS4S jjr~ SS\ESS4S jjr  SS\S\S\S\\S   Sr\\   SS4S jjr SSr\S\S\S\\S   SS4
S jjr  SSr\Sa\S\S\\S   Sq\pSt\qSS4S jjr  SSr\Sa\S\S\\S   Sq\pSt\qSS4S jjrSrS\\   4S jrS\\   4S jrS\\W\4   SS4S jrS\SS4S jrS\SS4S jr\S\\   4S j5       r\R                   S\SS4S j5       r\S\\   4S j5       r\R                   S\SS4S j5       rSrS\\   4S jrS\\   4S jrS\SS4S jrS\SS4S jr\S\\   4S j5       r\R                   S\SS4S j5       r\S\\   4S j5       r\R                   S\SS4S j5       rS\S\<\\4   SS4S jrS\\\4   S\4S jrS\\J\\84   S\K\\\   4   4S jr    SS\\\8\J4   Sg\\S\\K\\4   \K\\\4   \'\   4   S\S\\K\\4   \K\\\4   \'\   4   S\ES\\\'\   \K\S4   4      SS4S jjr\h" SgSS9    SS\\   S\\J\\84   Sg\\   S\\   S\ES\\\'\   \K\S4   4      SS4S jj5       rS\US\<\\4   S8\8S\4S jrS\\\4   S\<\\4   S8\8SS4S jrS\S\\\\Y4   S\<\\4   S8\8S\\   4S jrS\\\'\U   4   S\S\<\\4   S8\8S\'\0   4
S jrS\S\<\\4   S8\8S\'\0   4S jrS-\0S\^4S jr SS\'\0   Sb\\^\4   Sc\S\^\4   SS4S jjrSS jr SSg\<\\4   SV\\   S\\'\      4S jjr\h" SgSh9 SSg\<\\4   SV\\   S\\'\      4S jj5       r SS8\S\8\4   SS4S jjrSrg)	PdfWriter   z
This class supports writing PDF files out, given pages produced by another
class (typically :class:`PdfReader<PyPDF2.PdfReader>`).
fileobjreturnNc           	         SU l         / U l        0 U l        0 U l        [	        5       nUR                  [        [        R                  5      [        S5      [        [        R                  5      [        S5      [        [        R                  5      [        5       05        U R                  U5      U l        [	        5       nUR                  [        S5      [        [         R"                  SR%                  S5      -   5      05        U R                  U5      U l        [	        5       U l        U R(                  R                  [        [        R                  5      [        [*        R,                  5      [        [*        R.                  5      U R                  05        U R                  U R(                  5      U l        Xl        SU l        g )Ns   %PDF-1.3z/Pagesr   z	/ProducerPyPDF2zutf-16beF)_header_objects_idnum_hash_id_translatedr>   updaterB   PATYPECOUNTrD   KIDSr8   _add_object_pagesrJ   codecsBOM_UTF16_BEencode_info_root_objectCOCATALOGPAGES_rootrX   with_as_usage)selfrX   pagesinfos       F/var/www/auris/envauris/lib/python3.13/site-packages/PyPDF2/_writer.py__init__PdfWriter.__init__   sP   ")+8:9; !"277#Z%9288$l1o277#[]	
 &&u-  !;')=''(//**EE*	
 %%d+
 -.  277#Z

%;288$dkk	
 %%d&7&78
"    c                     SU l         U $ )z+Store that writer is initialized by 'with'.T)rp   rq   s    rt   	__enter__PdfWriter.__enter__   s    !rw   exc_typeexc	tracebackc                 ^    U R                   (       a  U R                  U R                   5        gg)zWrite data to the fileobj.N)rX   write)rq   r|   r}   r~   s       rt   __exit__PdfWriter.__exit__   s      <<JJt||$ rw   c                     U R                   $ )z
Header of the PDF document that is written.

This should be something like b'%PDF-1.5'. It is recommended to set the
lowest version that supports all features which are used within the
PDF file.
r\   ry   s    rt   
pdf_headerPdfWriter.pdf_header   s     ||rw   
new_headerc                     Xl         g Nr   )rq   r   s     rt   r   r      s    !rw   objc                    [        US5      (       a&  UR                  R                  U :X  a  UR                  $ U R                  R	                  U5        [        [        U R                  5      SU 5      Ul        UR                  $ )Nindirect_referencer   )hasattrr   pdfr]   appendrA   lenrq   r   s     rt   re   PdfWriter._add_object   sh    3,--#2H2H2L2LPT2T)))S!!/DMM0BAt!L%%%rw   r   idoc                 $   Ub+  Ub  [        S5      eUn[        R                  " S[        5        Uc   e[	        U[
        5      (       a  U R                  US-
     $ UR                  U :w  a  [        S5      eU R                  UR                  S-
     $ )NzGPlease only set 'indirect_reference'. The 'ido' argument is deprecated.zGThe parameter 'ido' is depreciated and will be removed in PyPDF2 4.0.0.r   zpdf must be self)	
ValueErrorwarningswarnDeprecationWarning
isinstanceintr]   r   idnum)rq   r   r   s      rt   
get_objectPdfWriter.get_object   s    
 ?!- ]  &)"]&
 *	
*(#..==!3a!788!!T)/00}}/559::rw   c                 >    [        SSS5        U R                  U5      $ )z=
.. deprecated:: 1.28.0

    Use :meth:`get_object` instead.
	getObjectr   3.0.0)r$   r   )rq   r   s     rt   r   PdfWriter.getObject   s     	%[,Hs##rw   pageactionexcluded_keysc                    [        [        U[        R                     5      [        R
                  :X  d   eUn[        U5      nU[        R                  S/-  n U R                  [        UR                  R                  5         UR                  R                  	 [        SUR                  U SU5      5      nUR                  bV  UR                  R                  n[!        U[        5      (       a  UR#                  5       n[%        U R                  U5      U l        U R&                  U[)        [        R                  5      '   [        [*        U R-                  U R&                  5      5      nUR                  c   eU" U[        R.                     UR                  5        [        [0        U[        R2                     5      n[5        US-   5      U[)        [        R2                  5      '   U$ ! [         a     GNZf = f)Nz/StructParentsr   Fr   )r   strra   rb   rl   PAGElistPARENTr_   idr   r   r   	Exceptioncloner   r   ri   r    rf   rB   r>   r   rd   r   rc   rD   )rq   r   r   r   page_orgotherrr   
page_counts           rt   	_add_pagePdfWriter._add_page   s    Cbgg'277222]+"))%566	##Bx'B'B'F'F$GH++11
 L(..um"LM<<#LL++E%%%9$//5QDO&*kkZ		"#%tt{{'CD&&222uRWW~t667#uRXX/
&2:>&Bj"#  		s   AG' '
G54G5c                     U R                   n[        R                  U;  aR  U R                   R                  [	        [        R                  5      [        [        U R                  5      SU 5      05        [	        [        R                  5      n[        S5      U R                   [        R                     U'   g ! [         a)  n[        R                  S[        U5      5         S nAg S nAff = f)Nr   Tz&set_need_appearances_writer() catch : )rk   r(   	ACRO_FORMr`   rB   rA   r   r]   r/   NeedAppearancesr9   r   loggererrorrepr)rq   catalogneed_appearancesr}   s       rt   set_need_appearances_writer%PdfWriter.set_need_appearances_writer  s    	N''G **'9!!(("#4#>#>?.4B  **D*T*TUO\]aObD/99:;KL 	NLLA49MM	Ns   B4B7 7
C*C%%C*c                 D    U R                  U[        R                  U5      $ )a:  
Add a page to this PDF file.
Recommended for advanced usage including the adequate excluded_keys

The page is usually acquired from a :class:`PdfReader<PyPDF2.PdfReader>`
instance.

:param PageObject page: The page to add to the document. Should be
    an instance of :class:`PageObject<PyPDF2._page.PageObject>`
)r   r   r   rq   r   r   s      rt   add_pagePdfWriter.add_page2  s     ~~dDKK??rw   c                 >    [        SSS5        U R                  X5      $ )z;
.. deprecated:: 1.28.0

    Use :meth:`add_page` instead.
addPager   r   )r$   r   r   s      rt   r   PdfWriter.addPageC  s     	%Y
GD}}T11rw   indexc                 0   ^ U R                  UU4S j5      $ )z
Insert a page in this PDF file. The page is usually acquired from a
:class:`PdfReader<PyPDF2.PdfReader>` instance.

:param PageObject page: The page to add to the document.
:param int index: Position at which the page will be inserted.
c                 (   > U R                  TU5      $ r   )insert)lpr   s     rt   <lambda>'PdfWriter.insert_page.<locals>.<lambda>]  s    %1Crw   )r   rq   r   r   r   s     ` rt   insert_pagePdfWriter.insert_pageP  s     ~~d$CDDrw   c                 @    [        SSS5        U R                  XU5      $ )z>
.. deprecated:: 1.28.0

    Use :meth:`insert_page` instead.

insertPager   r   )r$   r   r   s       rt   r   PdfWriter.insertPage_  s#     	%\='J];;rw   page_number
pageNumberc                 4   Ub  Ub  [        S5      e[        SSS5        UnUc  Uc  [        S5      e[        [        [        [
        4   U R                  U R                  5      5      n[        [        U[        R                     U   R                  5       5      $ )z
Retrieve a page by number from this PDF file.

:param int page_number: The page number to retrieve
    (pages begin at zero)
:return: the page at the index given by *page_number*
z)Please only use the page_number parameterzget_page(pageNumber)zget_page(page_number)4.0.0zPlease specify the page_number)r   r"   r   r   r   r
   r   rf   r   ra   rd   )rq   r   r   rr   s       rt   get_pagePdfWriter.get_pagem  s     !& !LMM&&(? %K:#5=>>T#s(^T__T[[%ABJbgg{ ; F F HIIrw   c                 >    [        SSS5        U R                  U5      $ )zL
.. deprecated:: 1.28.0

    Use :code:`writer.pages[page_number]` instead.
getPagezwriter.pages[page_number]r   )r$   r   )rq   r   s     rt   r   PdfWriter.getPage  s      	%Y0KWU}}Z((rw   c                     [        [        [        [        4   U R	                  U R
                  5      5      n[        U[        S5         5      $ )Nz/Count)r   r   r   r
   r   rf   r   rB   )rq   rr   s     rt   _get_num_pagesPdfWriter._get_num_pages  s8    T#s(^T__T[[%AB5H-.//rw   c                 <    [        SSS5        U R                  5       $ )zD
.. deprecated:: 1.28.0

    Use :code:`len(writer.pages)` instead.
getNumPageszlen(writer.pages)r   )r$   r   ry   s    rt   r   PdfWriter.getNumPages  s      	%]4GQ""$$rw   c                 B    [        U R                  U R                  5      $ )zNProperty that emulates a list of :class:`PageObject<PyPDF2._page.PageObject>`.)r   r   r   ry   s    rt   rr   PdfWriter.pages  s     D//??rw   widthheightc                 V    [         R                  " XU5      nU R                  U5        U$ )a  
Append a blank page to this PDF file and returns it. If no page size
is specified, use the size of the last page.

:param float width: The width of the new page expressed in default user
    space units.
:param float height: The height of the new page expressed in default
    user space units.
:return: the newly appended page
:raises PageSizeNotDefinedError: if width and height are not defined
    and previous page does not exist.
)r   create_blank_pager   )rq   r   r   r   s       rt   add_blank_pagePdfWriter.add_blank_page  s'     ++D@drw   c                 >    [        SSS5        U R                  X5      $ )zA
.. deprecated:: 1.28.0

    Use :meth:`add_blank_page` instead.
addBlankPager   r   )r$   r   )rq   r   r   s      rt   r   PdfWriter.addBlankPage  s"     	%^5EwO""511rw   c                    Ub  UcR  U R                  5       S-
  U:  a;  U R                  U   nUR                  R                  nUR                  R                  n[
        R                  " XU5      nU R                  XS5        U$ )a  
Insert a blank page to this PDF file and returns it. If no page size
is specified, use the size of the last page.

:param float width: The width of the new page expressed in default user
    space units.
:param float height: The height of the new page expressed in default
    user space units.
:param int index: Position to add the page.
:return: the newly appended page
:raises PageSizeNotDefinedError: if width and height are not defined
    and previous page does not exist.
r   )r   rr   mediaboxr   r   r   r   r   )rq   r   r   r   oldpager   s         rt   insert_blank_pagePdfWriter.insert_blank_page  sw    & =FN0C0C0E0Ie/Sjj'G$$**E%%,,F++D@%rw   c                 @    [        SSS5        U R                  XU5      $ )zB
.. deprecated:: 1.28.0

    Use :meth:`insertBlankPage` instead.
insertBlankPager   r   )r$   r   )rq   r   r   r   s       rt   r   PdfWriter.insertBlankPage  s%     	%%68KWU%%eU;;rw   c                 n   SU R                   ;  a  gU R                   S   n[        U[        [        45      (       a  [	        [        U5      5      $ [        U[
        5      (       a.   USS u  p#USS n[        U[        U5      5      n[        SX%5      $ g! [         a  n[        SU SU 35      eSnAff = f)aO  
Property to access the opening destination ("/OpenAction" entry in the
PDF catalog).
it returns `None` if the entry does not exist is not set.

:param destination:.
the property can be set to a Destination, a Page or an string(NamedDest) or
    None (to remove "/OpenAction")

(value stored in "/OpenAction" entry in the Pdf Catalog)
/OpenActionNr      
OpenActionzInvalid Destination : )
rk   r   r   bytesrJ   r8   r?   tupler=   r   )rq   oar   typarrayfitr}   s          rt   open_destinationPdfWriter.open_destination  s      1 11}-b3,'''B00K((DqG	12#uU|,"<;;   D"6rd"SE BCCDs   &,B 
B4B//B4destc                    Uc   U R                   S	 g [        U[        5      (       a"  [	        U5      U R                   [        S5      '   g [        U[        5      (       a#  UR                  U R                   [        S5      '   g [        U[        5      (       aS  [        SUR                  b  UR                  O	[        5       [        5      R                  U R                   [        S5      '   g g ! [         a     g f = f)Nr   Opening)rk   KeyErrorr   r   rH   rB   r=   
dest_arrayr   r   rC   r6   rq   r   s     rt   r   r     s    <%%m4 c"";KD;QDj78k**;???Dj78j));F**6 ''\< j j78 *  s   C+ +
C87C8
javascriptc           
         SU R                   ;  a.  [        5       U R                   [        [        R                  5      '   [        [        U R                   [        R                     5      nSU;  a*  [        [        S5      [        5       05      U[        S5      '   [        [        [        [        US   5      S   5      n[        5       nUR                  [        [        R                  5      [        S5      [        S5      [        S5      [        S5      [        U 5      05        UR                  [        [        [        R                  " 5       5      5      5        UR                  U R!                  U5      5        g)z
Add Javascript which will launch upon opening this PDF.

:param str javascript: Your Javascript.

>>> output.add_js("this.print({bUI:true,bSilent:false,bShrinkToFit:true});")
# Example: This will launch the print window when the PDF is opened.
z/Namesz/JavaScriptz/Action/Sz/JSN)rk   r>   rB   CANAMESr   r8   r`   ra   rb   rH   r   rJ   r   uuiduuid4re   )rq   r  namesjs_listjss        rt   add_jsPdfWriter.add_js  s    4,,,6F6HDj23%t'8'8'BC%/?H%{}50E*]+, .m0DEhO
 
		277#Z	%:4 *]";5!#3zl#D	
 	+C

,=>?t''+,rw   c                 >    [        SSS5        U R                  U5      $ )z9
.. deprecated:: 1.28.0

    Use :meth:`add_js` instead.
addJSr  r   )r$   r  )rq   r  s     rt   r  PdfWriter.addJS;  s     	%Wh@{{:&&rw   filenamedatac           	          [        5       nUR                  U5        UR                  [        [        R
                  5      [        S5      05        [        5       nUR                  [        S5      U05        [        5       nUR                  [        [        R
                  5      [        S5      [        [        R                  5      [        U5      [        [        R                  5      U05        [        5       nUR                  [        [        R                  5      [        [        U5      U/5      05        [        5       nUR                  [        S5      U05        U R                  R                  [        [        R                  5      U05        g)z
Embed a file inside the PDF.

:param str filename: The filename to display.
:param str data: The data in the file.

Reference:
https://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
Section 7.11.3
z/EmbeddedFile/Fz	/Filespecz/EmbeddedFilesN)r<   set_datar`   rB   ra   rb   r>   r-   FrJ   EFr	  r
  r8   rk   )rq   r  r  
file_entryef_entryfilespecembedded_files_names_dictionaryembedded_files_dictionarys           rt   add_attachmentPdfWriter.add_attachmentD  s@   8 )*
D!:bgg.
?0KLM $%D):67#%277#Z%<=??@BVC =@@A8	
* +;*<''..288$k)(3X>'	
 %5$6!!((()+JK	
 	  *RXX"68Q!RSrw   fnamefdatac                 >    [        SSS5        U R                  X5      $ )zA
.. deprecated:: 1.28.0

    Use :meth:`add_attachment` instead.
addAttachmentr!  r   )r$   r!  )rq   r#  r$  s      rt   r&  PdfWriter.addAttachment  s"     	%_6FP""500rw   readerafter_page_appendc                     [        UR                  5      n[        U5       H=  nUR                  U   nU R                  U5      n[	        U5      (       d  M5  U" U5        M?     g)an  
Copy pages from reader to writer. Includes an optional callback parameter
which is invoked after pages are appended to the writer.

:param PdfReader reader: a PdfReader object from which to copy page
    annotations to this writer object.  The writer's annots
    will then be updated
:param Callable[[PageObject], None] after_page_append:
    Callback function that is invoked after each page is appended to
    the writer. Signature includes a reference to the appended page
    (delegates to append_pages_from_reader). The single parameter of the
    callback is a reference to the page just appended to the document.
N)r   rr   ranger   callable)rq   r(  r)  reader_num_pagesreader_page_numberreader_pagewriter_pages          rt   append_pages_from_reader"PdfWriter.append_pages_from_reader  sU    & v||,"'(8"9 ,,'9:K--4K)**!+. #:rw   c                 @    [        SSS5        U R                  X5        g)zK
.. deprecated:: 1.28.0

    Use :meth:`append_pages_from_reader` instead.
appendPagesFromReaderr1  r   N)r$   r1  rq   r(  r)  s      rt   r4  PdfWriter.appendPagesFromReader  s$     	%#%?	
 	%%f@rw   fieldsflagsc           	         U R                  5         [        R                  U;  a  [        S[        5        g[        [        U[        R                     5      5       GH  nU[        R                     U   R                  5       n0 n[        R                  U;   a  U[        R                     nU GHM  nUR                  [        R                  5      U:X  a  UR                  [        R                  5      S:X  a5  UR                  [        [        R                   5      [        X'   5      05        UR                  [        [        R"                  5      [%        X'   5      05        U(       a5  UR                  [        [        R&                  5      [)        U5      05        M  M  UR                  [        R                  5      U:X  d  GM  UR                  [        [        R"                  5      [%        X'   5      05        GMP     GM     g)a=  
Update the form field values for a given page from a fields dictionary.

Copy field texts and values from fields to page.
If the field links to a parent object, add the information to the parent.

:param PageObject page: Page reference from PDF writer where the
    annotations and field data will be updated.
:param dict fields: a Python dictionary of field names (/T) and text
    values (/V)
:param int flags: An integer (0 to 7). The first bit sets ReadOnly, the
    second bit sets Required, the third bit sets NoExport. See
    PDF Reference Table 8.70 for details.
z No fields to update on this pageNz/Btn)r   PGANNOTSr%   __name__r+  r   r   r   getr+   TFTr`   rB   r&   ASVrH   FfrD   )rq   r   r7  r8  jwriter_annotwriter_parent_annotfields           rt   update_page_form_field_values'PdfWriter.update_page_form_field_values  s   ( 	((*99D =xHs4		?+,A		?1-88:L"$yyL(&2299&=###$=$?$?@EI#''(A(D(DEO$++ *$B$E$E!"#-fm#< !''&'@'B'BCEU &F $++ *+D+G+G H,$)K"  ),,-F-H-HIUR'..&'@'B'BCEU &F5   -rw   c                 @    [        SSS5        U R                  XU5      $ )zP
.. deprecated:: 1.28.0

    Use :meth:`update_page_form_field_values` instead.
updatePageFormFieldValuesrG  r   )r$   rG  )rq   r   r7  r8  s       rt   rJ  #PdfWriter.updatePageFormFieldValues  s)     	%')H'	
 11$FFrw   c                 d    [        [        UR                  [        R                     5      U l        g)zr
Copy the reader document root to the writer.

:param reader:  PdfReader from the document root should be copied.
N)r   r>   trailerTKROOTrk   rq   r(  s     rt   clone_reader_document_root$PdfWriter.clone_reader_document_root  s!     !!16>>"''3JKrw   c                 @    [        SSS5        U R                  U5        g)zM
.. deprecated:: 1.28.0

    Use :meth:`clone_reader_document_root` instead.
cloneReaderDocumentRootrQ  r   N)r$   rQ  rP  s     rt   rT  !PdfWriter.cloneReaderDocumentRoot%  s$     	%%'CW	
 	''/rw   c                 H    U R                  U5        U R                  X5        g)a  
Create a copy (clone) of a document from a PDF file reader

:param reader: PDF file reader instance from which the clone
    should be created.
:param Callable[[PageObject], None] after_page_append:
    Callback function that is invoked after each page is appended to
    the writer. Signature includes a reference to the appended page
    (delegates to append_pages_from_reader). The single parameter of the
    callback is a reference to the page just appended to the document.
N)rQ  r1  r5  s      rt   clone_document_from_reader$PdfWriter.clone_document_from_reader0  s     " 	''/%%f@rw   c                 @    [        SSS5        U R                  X5        g)zM
.. deprecated:: 1.28.0

    Use :meth:`clone_document_from_reader` instead.
cloneDocumentFromReaderrW  r   N)r$   rW  r5  s      rt   rZ  !PdfWriter.cloneDocumentFromReaderD  s$     	%%'CW	
 	''Brw   Tuser_passwordowner_password
use_128bitpermissions_flaguser_pwd	owner_pwdc           	      `   Ub&  Ub  [        S5      e[        R                  " S5        UnUc  [        S5      eUb3  Ub  [        S5      eSnSn[        R                  " U SU S	3[        S
9  UnUc  UnU(       a  Sn	Sn
[	        S5      nOSn	Sn
[	        S5      nUn[        [        X!X5      5      n[        [        [        [        R                  " 5       5      R                  S5      5      R                  5       5      n[        [        [        [        R                  " 5       5      R                  S5      5      R                  5       5      n[        X45      U l        U
S:X  a  [        XX5      u  nnOU
S:X  d   e[!        XXXS5      u  nn[#        5       n[%        S5      U[%        [&        R(                  5      '   [+        U	5      U[%        S5      '   U	S:X  a(  [+        US-  5      U[%        [&        R,                  5      '   [+        U
5      U[%        [.        R0                  5      '   [        U5      U[%        [.        R2                  5      '   [        U5      U[%        [.        R4                  5      '   [+        U5      U[%        [.        R6                  5      '   U R9                  U5      U l        UU l        g)a  
Encrypt this PDF file with the PDF Standard encryption handler.

:param str user_password: The "user password", which allows for opening
    and reading the PDF file with the restrictions provided.
:param str owner_password: The "owner password", which allows for
    opening the PDF files without any restrictions.  By default,
    the owner password is the same as the user password.
:param bool use_128bit: flag as to whether to use 128bit
    encryption.  When false, 40bit encryption will be used.  By default,
    this flag is on.
:param unsigned int permissions_flag: permissions as described in
    TABLE 3.20 of the PDF 1.7 specification. A bit value of 1 means the
    permission is grantend. Hence an integer value of -1 will set all
    flags.
    Bit position 3 is for printing, 4 is for modifying content, 5 and 6
    control annotations, 9 for form fields, 10 for extraction of
    text and graphics.
NzGPlease only set 'user_password'. The 'user_pwd' argument is deprecated.z|Please use 'user_password' instead of 'user_pwd'. The 'user_pwd' argument is deprecated and will be removed in PyPDF2 4.0.0.zuser_password may not be NonezIThe argument owner_pwd of encrypt is deprecated. Use owner_password only.ra  r]  G is deprecated as an argument and will be removed in PyPDF2 4.0.0. Use  insteadmessagecategoryr      g      0@r   g      @utf8Fz	/Standard/V   )r   r   r   r   r   r:   r   r   r   timeri   digestrandomr8   _IDr   r   r>   rB   SAFILTERrD   LENGTHEDROUPre   _encrypt_encrypt_key)rq   r\  r]  r^  r_  r`  ra  old_termnew_termrA  revkeylenrw  ru  ID_1ID_2rv  keyencrypts                      rt   r  PdfWriter.encryptS  s^   8 ( = 
 7
 !) <== ) _  '+#* %88@zK 0 "+!*NAC\FAC[FVN3OPT$))+%6$>$>v$F G N N PQT&--/%:$B$B6$J K R R TU|,!8Ma6FAs!8O8M1EJFAs"$)3K)@
299%&$0O
4 !6-9&1*-EGJryy)*$0$5
244 !$4Q$7
244 !$4Q$7
244 !$0O
244 !((1rw   streamc                    [        US5      (       a.  SUR                  ;  a  [        SUR                   S3[        5        U R
                  (       d   U R                  U R                  5      U l        U R                  U R
                  5        U R                  U5      nU R                  X5      nU R                  U5        UR                  [        SU S35      5        g )NmodebzFile <zH> to write to is not in binary mode. It may not be written to correctly.z
startxref
z
%%EOF
)r   r  r%   namer<  ro   re   rk   _sweep_indirect_references_write_header_write_xref_table_write_trailerr   r!   )rq   r  object_positionsxref_locations       rt   write_streamPdfWriter.write_stream  s    66""s&++'= &6 6 zz))$*;*;<DJ 	''

3--f5..vHF#R-i@ABrw   c                     SnUS:X  a  [        SU S35      e[        U[        [        45      (       a  [	        US5      nSU l        SnU R                  U5        U R
                  (       a  UR                  5         X!4$ )a5  
Write the collection of pages added to this object out as a PDF file.

:param stream: An object to write the file to.  The object can support
    the write method and the tell method, similar to a file object, or
    be a file path, just like the fileobj, just named it stream to keep
    existing workflow.
F zOutput(stream=z) is empty.wbT)r   r   r   r   r   rp   r  close)rq   r  my_files      rt   r   PdfWriter.write  sv     R<~fX[ABBfsDk**FD)F!%DG&!LLNrw   c           	      \   / nUR                  U R                  S-   5        UR                  S5        [        U R                  5       GH`  u  p4U R                  U   nUc  M  US-   nUR	                  UR                  5       5        UR                  [        [        U5      5      S-   5        S n[        U S5      (       a  XPR                  R                  :w  a  [        R                  " SUS-   5      S S n[        R                  " SS5      S S	 nU R                  U-   U-   n[        U5      [        U R                  5      S
-   :X  d   e[        U5      R!                  5       n	U	S [#        S[        U R                  5      S
-   5       nUR%                  X5        UR                  S5        GMc     U$ )N   
s   %
r   s    0 obj
rx  z<irh  r   r         s   
endobj
)r   r   	enumerater]   r   tellr!   r   r   rx  r   structpackry  r   r   rm  minwrite_to_stream)
rq   r  r  ir   r   r  pack1pack2md5_hashs
             rt   r  PdfWriter._write_header  sh   T__u,-+,.FA--"CA ''6RE
^k9:4,,--:M:M1M"KKa!e4Ra8E"KKa0!4E++e3e;Cs8D,=,=(>(BCCC"3x0H"#HSS1B1B-Ca-G%HIC##F0]+! /"  rw   r  c           	      J   UR                  5       nUR                  S5        UR                  [        S[        U R                  5      S-    S35      5        UR                  [        SS SSS	 S
35      5        U H%  nUR                  [        US SSS	 S35      5        M'     U$ )Ns   xref
z0 r   
r   z0>10 i  z0>5z f 
z n 
)r  r   r!   r   r]   )rq   r  r  r  offsets        rt   r  PdfWriter._write_xref_table  s    YR"S/!34B789R1T(!E#;e456&FLLvdm1QsG59:; 'rw   c           	      X   UR                  S5        [        5       nUR                  [        [        R
                  5      [        [        U R                  5      S-   5      [        [        R                  5      U R                  [        [        R                  5      U R                  05        [        U S5      (       a&  U R                  U[        [        R                  5      '   [        U S5      (       a&  U R                   U[        [        R"                  5      '   UR%                  US 5        g )Ns   trailer
r   ro  rx  )r   r>   r`   rB   rN  SIZErD   r   r]   rO  ro   INFOrj   r   ro  IDrx  ENCRYPTr  )rq   r  rM  s      rt   r  PdfWriter._write_trailer  s    \""$277#\#dmm2Dq2H%I277#TZZ277#TZZ	
 4)-GJruu%&4$$.2mmGJrzz*+-rw   infosc                     0 n[        UR                  5       5       H  u  p4[        U5      U[        U5      '   M     U R	                  U R
                  5      R                  U5        g)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.
N)r   itemsrJ   rB   r   rj   r`   )rq   r  argsr  values        rt   add_metadataPdfWriter.add_metadata  sN     u{{}-JC$8$?DC! .

#**40rw   c                 @    [        SSS5        U R                  U5        g)z?
.. deprecated:: 1.28.0

    Use :meth:`add_metadata` instead.
addMetadatar  r   N)r$   r  )rq   r  s     rt   r  PdfWriter.addMetadata!  s     	%]NGL% rw   rootc                 ^   [         R                  " 5       n/ nS n/ nS nUR                  XXe45        [        U5      (       Ga  UR	                  5       u  ptpe[        U[        [        45      (       a7  UR                  5        H"  u  pUR                  U	UUUb  XT/-   O/ 45        M$     O[        U[        5      (       am  UR                  U :w  a]  U R                  U5      n[        U5      U;  a=  UR                  [        U5      5        UR                  UR                  5       S S / 45        [        U[        [        45      (       a  [        U[        5      (       a   U R                  U R                  U5      5      n/ n
XF   U:w  a6  UR!                  5       /U Vs/ s H  oR!                  5       PM     sn-   n
XtU'   U
 HV  nU R"                  R	                  US 5      nUc  M$  UR                  5       nUc  M9  UU R"                  UR!                  5       '   MX     [        U5      (       a  GM  g g s  snf r   )collectionsdequer   r   popr   r8   r>   r  rA   r   _resolve_indirect_objectr   r   rG   re   
hash_valuer^   )rq   r  stack
discoveredparentgrant_parents	key_or_idr  r  r  update_hashesgrant_parentold_hashr   indirect_reference_objs                  rt   r  $PdfWriter._sweep_indirect_references*  s   ,  	 
)+	 	dI=>%jj5:YY[2D) $.> ?@@"&**,JCLL! 8>8JMH4PR	 #/ D.1188t#88>D4y
2"))#d)4doo&7tR%HI &#3["ABBdL11  889I9I$9OPD " $,%+%6%6%8$9FS=FSl//1m= %M )-9% !.H)-)9)9)=)=h)M&)51C1N1N1P.1= !3 !,, 6 A A C !.O %jjB=s   H*c                    [        UR                  S5      (       aQ  UR                  R                  R                  (       a,  [	        SUR                  R                  R
                   35      eUR                  U :X  a  U$ UR                  R                  U5      nUc5  [        SUR                  R                   SU S3[        5        [        5       nUR                  5       nX0R                  ;   a  U R                  U   $ UR                  U :X  a%  [        UR                  SU 5      U R                  U'   OU R                  U5      U R                  U'   U R                  U   $ )z
Resolves indirect object to this pdf indirect objects.

If it is a new object then it is added to self._objects
and new idnum is given and generation is always 0.
r  zI/O operation on closed file: zUnable to resolve [r   z], returning NullObject insteadr   )r   r   r  closedr   r  r   r%   	__class__r<  rC   r  r^   rA   r   re   )rq   r  real_objr  s       rt   r  "PdfWriter._resolve_indirect_object{  s/    488X&&488??+A+A=dhhoo>R>R=STUU88tK 88&&t,%dnn&=&=%>b G/ /
 "|H((*
 )))##J//88t+9$**a+NDZ( ,0+;+;H+EDZ(
++rw   c                     U R                   R                  U5      S-   n[        USU 5      nUR                  5       U:X  d   eU$ Nr   r   )r]   r   rA   r   )rq   r   r   refs       rt   get_referencePdfWriter.get_reference  sC    ##C(1,UAt,~~3&&&
rw   c                 >    [        SSS5        U R                  U5      $ )z@
.. deprecated:: 1.28.0

    Use :meth:`get_reference` instead.
getReferencer  r   )r$   r  r   s     rt   r  PdfWriter.getReference  s!     	%^_gN!!#&&rw   c                    [         R                  U R                  ;   ao  [        [        U R                  [         R                     5      nU R
                  R                  U5      S-   n[        USU 5      nUR                  5       U:X  d   e U$ [	        5       nUR                  0 5        U R                  U5      nX0R                  [        [         R                  5      '   U$ r  )rl   OUTLINESrk   r   rI   r]   r   rA   r   r`   re   rB   )rq   outliner   outline_refs       rt   get_outline_rootPdfWriter.get_outline_root  s    ;;$+++:t'8'8'EFGMM''014E(48K))+w666  !lGNN2**73K9Dj56rw   c                     [         R                  U R                  ;   a-  [        [        U R                  [         R                     5      nU$ [	        5       nXR                  [        [         R                  5      '   U$ )u   
the list of threads see §8.3.2 from PDF 1.7 spec

        :return: an Array (possibly empty) of Dictionaries with "/F" and "/I" properties
)rl   THREADSrk   r   r8   rB   )rq   threadss     rt   get_threads_rootPdfWriter.get_threads_root  s]     ::***;(9(9"**(EFG  "mG8?j45rw   c                 "    U R                  5       $ )u   
Read-only property for the list of threads see §8.3.2 from PDF 1.7 spec

:return: an Array (possibly empty) of Dictionaries with "/F" and "/I" properties
)r  ry   s    rt   r  PdfWriter.threads  s     $$&&rw   c                 <    [        SSS5        U R                  5       $ )zC
.. deprecated:: 1.28.0

    Use :meth:`get_outline_root` instead.
getOutlineRootr  r   )r$   r  ry   s    rt   r  PdfWriter.getOutlineRoot  s!     	%%57I7S$$&&rw   c                    [         R                  U R                  ;   Ga  [        U R                  [         R                     [        5      (       Ga[  [        [        U R                  [         R                     5      nUR                  n[         R                  U;   a  [        U[         R                     [        5      (       a  [        [        U[         R                     5      nUR                  n[         R                  U;   a#  [        [        U[         R                     5      nU$ [        5       nXS[        [         R                  5      '    U$ [	        5       nU R                  U5      nXA[        [         R                  5      '   [        5       nXS[        [         R                  5      '    U$ [	        5       nU R                  U5      nX R                  [        [         R                  5      '   [	        5       nU R                  U5      nXA[        [         R                  5      '   [        5       nXS[        [         R                  5      '   U$ r   )r	  r
  rk   r   r>   r   r   DESTSr8   rB   re   )rq   r  	names_refdests	dests_refnds         rt   get_named_dest_rootPdfWriter.get_named_dest_root  s   88t(((Zbhh')9.
 .
 )4+<+<RXX+FGE00Ixx5 ZbhhAQ%R%R-uRXX?!44	88u$k5?;B* 	' %B24*RXX./$ 	! )* ,,U3	.7j*+ ].0j*+ 	 %&E((/I6?j23$&E((/I*3*RXX&'B*,*RXX&'	rw   c                 <    [        SSS5        U R                  5       $ )zF
.. deprecated:: 1.28.0

    Use :meth:`get_named_dest_root` instead.
getNamedDestRootr  r   )r$   r  ry   s    rt   r  PdfWriter.getNamedDestRoot  s"     	%%79NPWX''))rw   page_destinationr  beforec                 Z   Ub  Ub  [        S5      eUb%  SnSn[        R                  " U SU S3[        S9  UnUc  [        S5      eUc  U R	                  5       n[        [        UR                  5       5      nU R                  U5      nUb  UR                  nUR                  XsU 5        U$ )Nz[The argument dest of add_outline_item_destination is deprecated. Use page_destination only.r   r  rc  rd  re   page_destination may not be None)r   r   r   r   r  r   rI   r   re   r   insert_child)rq   r  r  r  r   rz  r{  page_destination_refs           rt   add_outline_item_destination&PdfWriter.add_outline_item_destination  s     'D,<m  H)HMMj !44<:XG ,  $#?@@>**,Fj&"3"3"56#//0@A..F0$?##rw   c                 >    [        SSS5        U R                  X5      $ )zN
.. deprecated:: 2.9.0

    Use :meth:`add_outline_item_destination` instead.
add_bookmark_destinationr  r   r$   r  rq   r   r  s      rt   r  "PdfWriter.add_bookmark_destination0  s'     	%&(F	
 00>>rw   c                 >    [        SSS5        U R                  X5      $ )zO
.. deprecated:: 1.28.0

    Use :meth:`add_outline_item_destination` instead.
addBookmarkDestinationr  r   r  r  s      rt   r   PdfWriter.addBookmarkDestination?  s'     	%$&Dg	
 00>>rw   outline_item)bookmarkc                    [        5       n[        UR                  5       5       H  u  pVXd[        [	        U5      5      '   M     UR                  U5        SU;   as  [        5       n[        [        US   5      n[        UR                  5       5       H  u  pVXg[        [	        U5      5      '   M     U R                  U5      n	X[        S5      '   U R                  XBU5      $ )N/A)
rI   r   r  rB   r   r`   r>   r   re   r  )
rq   r  r  r  outline_item_objectkvr   a_dict
action_refs
             rt   add_outline_item_dictPdfWriter.add_outline_item_dictL  s     )l++-.DA67
3q6 23 /""<0<%'F*L,>?FV\\^,-.z#a&)* -))&1J4>
4 01001DfUUrw   c                 >    [        SSS5        U R                  X5      $ )zG
.. deprecated:: 2.9.0

    Use :meth:`add_outline_item_dict` instead.
add_bookmark_dictr  r   r$   r  rq   r  r  s      rt   r  PdfWriter.add_bookmark_dictb  s'     	%!8'	
 )),??rw   c                 >    [        SSS5        U R                  X5      $ )zH
.. deprecated:: 1.28.0

    Use :meth:`add_outline_item_dict` instead.
addBookmarkDictr  r   r  r  s      rt   r  PdfWriter.addBookmarkDictp  s'     	%6	
 )),??rw   Ftitlecolorbolditalicr   pagenumc
           
      8   [        U[        5      (       a  Ub  Uc  UnU R                  XUSXEXg5      $ Ub  U	b  [        S5      eUc  Sn
GO[        U[        5      (       a  UnOQ[        U[
        5      (       a  UR                  nO/[        U[        5      (       a   U R                  U   R                  nWc  [        SU 3[        5        [        5       n[        [        SU-   S-   5      UU5      nU R!                  [#        [        [$        R&                  5      UR(                  [        [$        R*                  5      [        S5      05      5      n
[-        XXWU5      nUc  U R/                  5       nU R1                  XU5      $ ! [         a    [        U5      n Nf = f)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 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 or as a Hex String (#RRGGBB)
:param bool bold: Outline item font is bold
:param bool italic: Outline item font is italic
:param Fit fit: The fit of the destination page.
NMThe argument pagenum of add_outline_item is deprecated. Use page_number only.zcan not find reference of page /z outline item/GoTo)r   r?   add_outline_itemr   rA   r   r   r   rr   
IndexErrorrD   r%   r<  rC   r=   rB   re   r>   r.   Dr  S_create_outline_itemr  r  )rq   r  r   r  r  r  r  r  r   r  r  page_refr   r  s                 rt   r  PdfWriter.add_outline_item~  s   8 fc"";#6!((FD&  "w':_  J+~66&K44&99K--9#zz+6IIH 5k]C &<3;89D )) "#6#8#894??"#6#8#89:g;NJ ,JudS>**,F00vNN5 " 9+K8H9s   F FFr  c                 X    [        SSS5        U R                  UUUUUU[        XxS95      $ )zB
.. deprecated:: 2.9.0

    Use :meth:`add_outline_item` instead.
add_bookmarkr  r   fit_typefit_argsr$   r  r?   	rq   r  r  r  r  r  r  r   r  s	            rt   r'  PdfWriter.add_bookmark  s>      	%^5GQ$$,
 	
rw   c                 Z    [        SSS5        U R                  UUUSUUU[        XxS95      $ )zC
.. deprecated:: 1.28.0

    Use :meth:`add_outline_item` instead.
addBookmarkr  r   Nr(  r+  r,  s	            rt   r/  PdfWriter.addBookmark  sA      	%]4FP$$,	
 		
rw   c                     [        S5      e)NzIThis method is not yet implemented. Use :meth:`add_outline_item` instead.)NotImplementedErrorry   s    rt   add_outlinePdfWriter.add_outline  s    !W
 	
rw   destinationc                    U R                  5       nSnU[        U5      :  aK  XU   :  a-  UR                  XB5        UR                  U[        U5      5        g US-  nU[        U5      :  a  MK  UR	                  [        U5      U/5        g )Nr   r   )r  r   r   rH   extend)rq   r  r5  r  r  s        rt   add_named_destination_array%PdfWriter.add_named_destination_array  s     %%'#b'k!u}		!)		!-e45Q #b'k 			#E*K89rw   c                    Ub  Ub  [        S5      eUb%  SnSn[        R                  " U SU S3[        S9  UnUc  [        S5      eU R	                  UR
                  5      nU R                  [        SUS	   5      U5        U$ )
Nz[The argument dest of add_named_destination_object is deprecated. Use page_destination only.r   r  rc  rd  re  r  rH   /Title)r   r   r   r   re   r  r8  r   )rq   r  r   rz  r{  r  s         rt   add_named_destination_object&PdfWriter.add_named_destination_object  s    
 'D,<m  H)HMMj !44<:XG ,  $#?@@#//0@0K0KL((#%5h%?@BV	
 $#rw   c                 >    [        SSS5        U R                  U5      $ )zO
.. deprecated:: 1.28.0

    Use :meth:`add_named_destination_object` instead.
addNamedDestinationObjectr<  r   )r$   r<  r  s     rt   r?  #PdfWriter.addNamedDestinationObject3  s'     	%')G	
 0066rw   c           
         Ub  Ub  [        S5      eUb%  SnSn[        R                  " U SU S3[        S9  UnUc  [        S5      eU R	                  U R
                  5      [        R                     U   n[        5       nUR                  [        [        R                  5      [        U[        [        R                  5      [!        S5      /5      [        [        R"                  5      [        S	5      05        U R%                  U5      nU R'                  5       n	[)        U[*        5      (       d  [+        [-        U5      5      nU	R/                  X/5        U$ )
Nr  r  r   rc  rd  re  zpage_number may not be Nonei:  r  )r   r   r   r   r   rf   ra   rd   r>   r`   rB   r.   r!  r8   r4   FIT_HrD   r"  re   r  r   rH   r   r7  )
rq   r  r   r  rz  r{  r$  r   dest_refr  s
             rt   add_named_destinationPdfWriter.add_named_destination@  sC    "w':_   H$HMMj !44<:XG , "K:;;??4;;/8E!.001;z/*?*?@,sBST4 .001:g3F		
 ##D)%%'%!122$SZ0E
		5#$rw   c                 >    [        SSS5        U R                  X5      $ )zH
.. deprecated:: 1.28.0

    Use :meth:`add_named_destination` instead.
addNamedDestinationrD  r   )r$   rD  )rq   r  r  s      rt   rG  PdfWriter.addNamedDestinationi  s'     	%!#:G	
 ))%99rw   c                 6   [        [        U R                  U R                  5      5      n[        [        U[
        R                     5      nU HI  n[        [        U R                  U5      5      n[        R                  U;   d  M8  U[        R                  	 MK     g)z.Remove links and annotations from this output.N)	r   r>   r   rf   r8   ra   rd   r:  r;  )rq   pg_dictrr   r   r$  s        rt   remove_linksPdfWriter.remove_linksv  si    ')EF['"''"23D,dood.CDHyyH$RYY' rw   c                 <    [        SSS5        U R                  5       $ )z?
.. deprecated:: 1.28.0

    Use :meth:`remove_links` instead.
removeLinksrK  r   )r$   rK  ry   s    rt   rN  PdfWriter.removeLinks  s     	%]NGL  ""rw   ignore_byte_string_objectc                    [        [        U R                  U R                  5      5      n[        [        U[
        R                     5      nSnU GH  n[        [        U R                  U5      5      nUS   R                  5       n[        U[        5      (       d  [        Xv5      n/ nSn	UR                   GH  u  pUS;   a/  U
S   nU(       a"  [        U[        5      (       d  [        5       U
S'   OUS:X  a/  U
S   nU(       a"  [        U[        5      (       d  [        5       U
S'   OZUS:X  aT  [        [        U
S   5      5       H9  nU(       d  M  [        U
S   U   [        5      (       a  M)  [        5       U
S   U'   M;     US	:X  a  S
n	US:X  a  Sn	U	(       a  X;   a  M  US:X  a  M  UR                  X45        GM     Xl	        UR                  [        S5      U5        GM     g)z~
Remove images from this output.

:param bool ignore_byte_string_object: optional parameter
    to ignore ByteString Objects.
)s   cm   w   J   j   M   ds   ri   is   gs   W   b   s   S   f   F   n   m   l   c   v   y   h   Bs   Dos   sh	/ContentsFs   Tj   'r      "r      TJ   qT   Qs   reN)r   r>   r   rf   r8   ra   rd   r   r;   
operationsrH   r+  r   r   __setitem__rB   )rq   rP  rJ  rr   jump_operatorsr   r$  content_operationsseq_graphicsoperandsoperatortextr  s                 rt   remove_imagesPdfWriter.remove_images  s    ')EF['"''"23
6 D,dood.CDH{+668Gg}55':K L&-&8&8"},#A;D0.: : '7&8%#A;D0.: : '7&8&"3x{#3444Z$QKN,<> > .>-?HQKN	 5 t##'Lt##(LH$>u$""H#789 '9< "-  K!8'BO rw   ignoreByteStringObjectc                 >    [        SSS5        U R                  U5      $ )z@
.. deprecated:: 1.28.0

    Use :meth:`remove_images` instead.
removeImagesrv  r   )r$   rv  rq   rx  s     rt   rz  PdfWriter.removeImages  s"     	%^_gN!!"899rw   c                 r   [        [        U R                  U R                  5      5      n[        [        [
           U[        R                     5      nU GH  n[        [        U R                  U5      5      nUS   R                  5       n[        U[        5      (       d  [        Xe5      nUR                   GH]  u  pxUS;   a^  US   n	U(       d&  [        U	[        5      (       a  [        5       US'   M<  M>  [        U	[        [        45      (       a  [        5       US'   Mh  Mj  US:X  a^  US   n	U(       d&  [        U	[        5      (       a  [        5       US'   M  M  [        U	[        [        45      (       a  [        5       US'   M  M  US:X  d  M  [        [        US   5      5       Hl  n
U(       d/  [        US   U
   [        5      (       a  [        5       US   U
'   M7  M9  [        US   U
   [        [        45      (       d  M\  [        5       US   U
'   Mn     GM`     UR!                  [#        S5      U5        GM     g)z|
Remove text from this output.

:param bool ignore_byte_string_object: optional parameter
    to ignore ByteString Objects.
rf  rg  r   ri  r   rj  N)r   r>   r   rf   r   rA   ra   rd   r   r   r;   rm  rH   r:   r+  r   rn  rB   )rq   rP  rJ  rr   r   r$  rp  rs  rt  ru  r  s              rt   remove_textPdfWriter.remove_text  s    ')EFT.)7277+;<DJ(=>H{+668Gg}55':&-&8&8"},#A;D4%d,<==*:*<HQK > &d-=?O,PQQ*:*<HQK R%#A;D4%d,<==*:*<HQK > &d-=?O,PQQ*:*<HQK R&"3x{#348)(1+a.:JKK1A1CA  L  * (A1ACS0T    2B1CA 5% '98   K!8'BC rw   c                 >    [        SSS5        U R                  U5      $ )z>
.. deprecated:: 1.28.0

    Use :meth:`remove_text` instead.

removeTextr~  r   )r$   r~  r{  s     rt   r  PdfWriter.removeText  s"     	%\='J 677rw   urirectborderc                    Ub  [         R                  " S[        S9  UnU R                  U R                  5      [
        R                     U   n[        [        [        [        4   U R                  U5      5      nUbg  USS  Vs/ s H  n[        U5      PM     n	n[        U5      S:X  a9  [        US    Vs/ s H  n[        U5      PM     sn5      n
U	R                  U
5        O[        S5      /S-  n	[!        U[        5      (       a  [        U5      nO![!        U["        5      (       a  O[#        U5      n[%        5       nUR'                  [        S5      [        S5      [        S5      [)        U5      05        [%        5       nUR'                  [        [*        R,                  5      [        [.        R0                  5      [        [*        R2                  5      [        S	5      [        [*        R4                  5      U[        [*        R6                  5      U[        S
5      [        S5      [        [*        R8                  5      [        U	5      [        S5      U05        U R;                  U5      n[.        R0                  U;   a#  U[.        R0                     R                  U5        g[        U/5      U[        [.        R0                  5      '   gs  snf s  snf )a  
Add an URI from a rectangular area to the specified page.
This uses the basic structure of :meth:`add_link`

:param int page_number: index of the page on which to place the URI action.
:param str uri: URI of resource to link to.
:param Tuple[int, int, int, int] rect: :class:`RectangleObject<PyPDF2.generic.RectangleObject>` or array of four
    integers specifying the clickable rectangular area
    ``[xLL, yLL, xUR, yUR]``, or string in the form ``"[ xLL yLL xUR yUR ]"``.
:param ArrayObject border: if provided, an array describing border-drawing
    properties. See the PDF spec for details. No border will be
    drawn if this argument is omitted.
NzoThe 'pagenum' argument of add_uri is deprecated and will be removed in PyPDF2 4.0.0. Use 'page_number' instead.)rg  rh     r   r  z/URI/Linkz/H/Ir  )r   r   r   r   rf   ra   rd   r   r   r   r
   rB   r   r8   r   rD   r   rF   r>   r`   rH   r&   r   r:  r;  Subtyperw  RectBorderre   )rq   r   r  r  r  r  	page_linkr$  n
border_arrdash_patternlnk2lnklnk_refs                 rt   add_uriPdfWriter.add_uri  s9   * MMF+
 "KOODKK09+F	S#X	(BC 17<A*Q-J<6{a*6!9+M9aJqM9+MN!!,/&q/*Q.JdC  d#Do.."4(D!4 *V"46"$4S$9	
  

9>>?BIIAV9AABJwDW9;;<i9>>?4 *T"29@@A;D 4 $
	
 ""3'99 RYY&&w/.97).DHZ		*+Q =+Ms   K6Kc                 @    [        SSS5        U R                  XX45      $ )z:
.. deprecated:: 1.28.0

    Use :meth:`add_uri` instead.
addURIr  r   )r$   r  )rq   r  r  r  r  s        rt   r  PdfWriter.addURIb  s!     	%Xy'B||G$77rw   c           
         [        SS5        [        U[        5      (       aY  UR                  5       SS n[	        UR                  S5       Vs/ s H  n[        U5      S:  d  M  [        U5      PM!     sn5      nO![        U[        5      (       a  O[	        U5      n[        R                  " UUU[        XVS9S9nU R                  XS	9$ s  snf )
Nadd_link+add_annotation(AnnotationBuilder.link(...))r   r  r   r(  )r  r  target_page_indexr   )r   
annotation)r$   r   r   striprF   splitr   floatr7   linkr?   add_annotation)	rq   r  r  r  r  r   r  numr  s	            rt   r  PdfWriter.add_linkq  s     	%E	
 dC  ::<"%D"'+zz#G#c(Q,sGD o.."4(D&++.S0	

 ""w"NN Hs   C	$C	c                 F    [        SSS5        U R                  " XX4U/UQ76 $ )z;
.. deprecated:: 1.28.0

    Use :meth:`add_link` instead.
addLinkr  r   )r"   r  )rq   r  r  r  r  r   r  s          rt   r  PdfWriter.addLink  s.     	#Dg	
 }}WcQDQQrw   )z	/NoLayoutz/SinglePagez
/OneColumnz/TwoColumnLeftz/TwoColumnRightz/TwoPageLeftz/TwoPageRightc                 ^     [        [        U R                  S   5      $ ! [         a     g f = f)N/PageLayout)r   rP   rk   r  ry   s    rt   _get_page_layoutPdfWriter._get_page_layout  s1    	
D$5$5m$DEE 		    
,,c                 <    [        SSS5        U R                  5       $ )A
.. deprecated:: 1.28.0

    Use :py:attr:`page_layout` instead.
getPageLayoutpage_layoutr   )r$   r  ry   s    rt   r  PdfWriter.getPageLayout  s     	%_mWM$$&&rw   layoutc                 
   [        U[        5      (       dH  XR                  ;  a.  [        SSSR	                  U R                  5      4 3[
        5        [        U5      nU R                  R                  [        S5      U05        g)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
zLayout should be one of: r  r  N)r   rB   _valid_layoutsr%   joinr<  rk   r`   rq   r  s     rt   _set_page_layoutPdfWriter._set_page_layout  sq    0 &*--000/BGGD<O<O4P0P/QR  'F  *]";V!DErw   c                 &    U R                  U5        g)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r  r  s     rt   set_page_layoutPdfWriter.set_page_layout  s    0 	f%rw   c                 >    [        SSS5        U R                  U5      $ )r  zwriter.setPageLayout(val)zwriter.page_layout = valr   )r$   r  r  s     rt   setPageLayoutPdfWriter.setPageLayout  s'     	%')CW	
 $$V,,rw   c                 "    U R                  5       $ )aK  
Page layout property.

.. 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
)r  ry   s    rt   r  PdfWriter.page_layout  s    . $$&&rw   c                 &    U R                  U5        g r   r  r  s     rt   r  r    s    f%rw   c                 4    [        SSS5        U R                  $ )r  
pageLayoutr  r   r$   r  ry   s    rt   r  PdfWriter.pageLayout  s     	%\='Jrw   c                 *    [        SSS5        Xl        g)r  r  r  r   Nr  r  s     rt   r  r  )  s     	%\='J!rw   )z/UseNonez/UseOutlinesz
/UseThumbsz/FullScreenz/UseOCz/UseAttachmentsc                 ^     [        [        U R                  S   5      $ ! [         a     g f = f)N	/PageMode)r   rS   rk   r  ry   s    rt   _get_page_modePdfWriter._get_page_mode<  s1    	d&7&7&DEE 		r  c                 <    [        SSS5        U R                  5       $ )?
.. deprecated:: 1.28.0

    Use :py:attr:`page_mode` instead.
getPageMode	page_moder   )r$   r  ry   s    rt   r  PdfWriter.getPageModeB  s     	%]KI""$$rw   r  c                    [        U[        5      (       a  UnOFXR                  ;  a,  [        SSR	                  U R                  5       3[
        5        [        U5      nU R                  R                  [        S5      U05        g)r  zMode should be one of: z, r  N)r   rB   _valid_modesr%   r  r<  rk   r`   )rq   r  	mode_names      rt   set_page_modePdfWriter.set_page_modeK  sp     dJ''$(I,,,-dii8I8I.J-KLh #4(I  *["99!EFrw   c                 @    [        SSS5        U R                  U5        g)r  zwriter.setPageMode(val)zwriter.page_mode = valr   N)r$   r  rq   r  s     rt   setPageModePdfWriter.setPageMode[  s$     	%%'?	
 	4 rw   c                 "    U R                  5       $ )a  
Page mode property.

.. 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
)r  ry   s    rt   r  PdfWriter.page_modef  s    * ""$$rw   c                 &    U R                  U5        g r   )r  r  s     rt   r  r  }  s    4 rw   c                 4    [        SSS5        U R                  $ )r  pageModer  r   r$   r  ry   s    rt   r  PdfWriter.pageMode  s     	%ZgF~~rw   c                 *    [        SSS5        Xl        g)r  r  r  r   Nr  r  s     rt   r  r    s     	%ZgFrw   r  c           
      z   [        [        [        U5      5      nU R                  U R                  5      S   U   U[        S5      '   U R                  U   nUR                  c  [        5       U[        S5      '   UR                  c   eUR                  S5      S:X  as  [        S5      U;   ad  [        [        U[        S5         5      n[        [        S5      US   [        US	   [        U5      S
   S95      nUR                  U[        S5      '   U R                  U5      nUR                  R                  U5        g )Nz/Kids/P/Annots/Subtyper  /Destz	/LinkNamer  r   r*  r(  )r   r>   _pdf_objectifyr   rf   rB   rr   annotationsr8   r=  dictr=   r?   r  re   r   )rq   r   r  to_addr   tmpr   ind_objs           rt   r  PdfWriter.add_annotation  s   &z(BC#'??4;;#?#H#Uz$ zz+&#*5-DI&'+++ ::j!W,G1D1NtVJw$789C;''( Z$s)J2GD +///F:g&'""6*(rw   c                    [        SUR                  5       5      nUR                  S/ 5       H  nUR                  5       nUR                  SS5      nUR                  SS5      n[        U[        5      (       a  [        U5      U[	        S5      '   Me  Uc  Mj  UR                  5       nUR                  SS5      n[        U[        5      (       d  M  [        U5      U[	        S5      '   M     U$ )z
Perform some clean up in the page.
Currently: convert NameObject nameddestination to TextStringObject (required for names/dests list)
r   r  r  Nr  /D)r   r   r=  r   rB   rH   )rq   r   aa_objdacts         rt   
clean_pagePdfWriter.clean_page  s    
 L$//"34)R(ALLNE		'4(A))D$'C!Z((-=a-@j)*nn&GGD$'a,,,<Q,?C
4() ) rw   c                    S n[        U[        [        45      (       a1  [        US5       n[	        UR                  5       5      nS S S 5        XB4$ [        U[        5      (       a  UR                  (       a  UR                  nUR                  R                  5       nUR                  R                  S5        [	        UR                  R                  5       5      nUR                  R                  U5        XB4$ [        US5      (       a@  [        US5      (       a/  UR                  S5        UR                  5       n[	        U5      nXB4$ [        S5      e! , (       d  f       WU4$ = f)Nrbr   seekreadzPdfMerger.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   r   r   r   r   r  r   _encryptionr  r  r  r   r2  )rq   rX   encryption_objfr  	orig_tellfilecontents          rt   _create_streamPdfWriter._create_stream  s3    gT{++&! * ', %%) ++""!(!4!4++-INN"W^^0023F NN	* %% Wf%%''6*B*BLLO!,,.K[)F %% &> ! '&, ~%%s   E
E$rr   import_outlineexcluded_fields.c                    Uc  Sn[        U[        [        [        45      (       aF  [        U[        5      (       a  [        U[        5      (       d  UnUnUnU R                  SUSX4U5        gU R                  SXX4U5        g)a  
Identical to the :meth:`merge()<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 a string to build an outline
    (aka 'bookmark') to identify the
    beginning of the included file.

:param pages: can be a :class:`PageRange<PyPDF2.pagerange.PageRange>`
    or a ``(start, stop[, step])`` tuple
    or a list of pages to be processed
    to merge only the specified range of pages from the source
    document into the output document.

: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``.

:param List excluded_fields: provide the list of fields/keys to be ignored
    if "/Annots" is part of the list, the annotation will be ignored
    if "/B" is part of the list, the articles will be ignored
N )r   r   r   rL   boolmerge)rq   rX   r  rr   r  r  s         rt   r   PdfWriter.append  sv    N " OlUD)$<==%&&!.$77&4O!& EJJtWdE?SJJgUOrw   )r  import_bookmarkspositionc           
      2   [        U[        5      (       a  UnOU R                  U5      u  p[        USS9nUc  SnUc)  [        [	        S[        UR                  5      5      5      nO[        U[        5      (       a4  [        [	        UR                  [        UR                  5      5      6 5      nOl[        U[        5      (       a  OV[        U[        5      (       a!  [        U5      S::  a  [        [	        U6 5      nO [        U[        5      (       d  [        S5      e0 n
U H  nUR                  U   nUR                  c   eUc7  U R                  U[        U5      SS	/-   5      XR                  R                  '   O;U R                  X[        U5      SS	/-   5      XR                  R                  '   US
-  nXUR                  R                     l        M     UR                   Ul        UR"                  R%                  5        H  nUR&                  n[        US   [(        5      (       a  M)  US   R                  R                  U
;   d  MH  U
US   R                  R                     R                  U[+        S5      '   U R-                  US   U5        M     Ub[  [/        SU R1                  [3        U5      [        U
R%                  5       5      S   R                  [4        S9R7                  5       5      nOU R9                  5       n[/        SUR:                  [<        R>                     5      nU(       aW  [@        RB                  U;   aC  U RE                  URG                  [@        RB                  S5      X5      nU RI                  UUS5        S	U;  ar  U
R%                  5        H^  nU RK                  UR                  RG                  S	S5      UX5      n[        U5      S:  a  UU[M        S	5      '   U RO                  U5        M`     SU;  a  U RQ                  SX5        g)a  
Merge the pages from the given file into the output file at the
specified page number.

:param int position: 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 a string to build an outline
    (aka 'bookmark') to identify the
    beginning of the included file.

:param pages: can be a :class:`PageRange<PyPDF2.pagerange.PageRange>`
    or a ``(start, stop[, step])`` tuple
    or a list of pages to be processed
    to merge only the specified range of pages from the source
    document into the output document.

: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``.

:param List excluded_fields: provide the list of fields/keys to be ignored
    if "/Annots" is part of the list, the annotation will be ignored
    if "/B" is part of the list, the articles will be ignored
F)strictNr  r   rh  z:"pages" must be a tuple of (start, stop[, step]) or a list/Br  r   /Pager;  rI   )r   r>   r  ))r   r   r   r   r+  r   rr   rL   indicesr   	TypeErrorr   r   r   r   original_pagenamed_destinations_namedDestsvaluesr  rC   rD   r8  r   r  rH   r6   r   r  rM  rN  rO  rl   r  _get_filtered_outliner=  _insert_filtered_outline_insert_filtered_annotationsrB   r  add_filtered_articles)rq   r
  rX   r  rr   r  r  r(  r  r  srcpagesr  pgr   arroutline_item_typ_ror  paglsts                       rt   r  PdfWriter.merge	  s   N gy))F%)%8%8%A"F ve4F" O=q#fll"345Ey))c&,,.? @ABEt$$u%%#e*/'EE5))L  AaB((4448<_-y0AA9..445 9=8H8H$"74:K"K9..445 ABDR**001?  %% 	 &&--/D//C$w-44g11778C'/M44::($$ LO$ 00hE 0 ##%%$\2*+A.AA  &  *,   $446%v~~bgg'>?bkkS000T*HG )))4 O+(77%%)))R8#x s8a<14C
9-.$ ) &&&r8<rw   threadc           
      8   UR                  U SSS9nU R                  R                  UR                  5        [	        SUS   5      nUnSnUGb  U R                  [	        SUS   5      X#5      nUGbD  UcL  [	        SU R                  [        5       5      R                  5       5      nUn	UR                  U[        S5      '   Oa[	        SU R                  [        [        S	5      UR                  05      5      R                  5       5      n
U
R                  U[        S
5      '   U
nX[        S5      '   UR                  U[        S5      '   US   U[        S5      '   [	        SUR                  5       5      nSU;  a  [        5       U[        S5      '   [	        SUS   5      R                  UR                  5        [	        SUS
   5      nXe:X  a2  W	R                  U[        S
5      '   UR                  U	[        S	5      '   SnUb  GM  UR                  c   eUR                  $ )z5
clone the thread with only the applicable articles

T)r  )force_duplicateignore_fieldsr>   r  Nr   r  rj  z/N/Tz/Rr  r8   )r   r  r   r   r   _get_cloned_pagere   r>   r   rB   r8   )rq   r!  rr   r(  nthreadfirst_articlecurrent_articlenew_articler  	new_firstnew_article2pag_objs               rt   _add_articles_threadPdfWriter._add_articles_thread	  s    ,,$g  
 	G667/>6C26)''\?4#895C &"&*(()9);<GGI#K !,I0;0N0NGJt,-#'*((,!+D!1;3Q3Q R %*,$L 5A4S4SK
4 01".K03Jt,-070J0JJt,-0?0EJt,-|S^^-=>w&0;GJt,-]GDM29922 ##5t7LMO/090L0LJt,-.9.L.L	*T*+"&I )J ))555)))rw   fltrc                    [        U[        5      (       a  [        R                  " U5      nO+[        U[        5      (       d  [        R                  " S5      nUR                  5        H  nUR                  nUR                  SS5       Hx  nUR                  5       S   nUR                  R                  U R                  [        U5         ;  d  MH  UR                  US   S   5      (       d  Mf  U R                  XrU5        Mz     M     g)z,
Add articles matching the defined criteria
r  r  r  r%  r  r;  N)r   r   recompiler   r  r  r=  r   r   r   r_   r   searchr.  )rq   r0  rr   r(  r   ppr  thrs           rt   r  PdfWriter.add_filtered_articles	  s     dC  ::d#DD'**::b>DABVVD"%llnT*))//t7J7JvJ8 kk#d)H"566--c&A &  rw   c                 ~   [        U[        5      (       a  g [        U[        5      (       a  UR                  U   R                  nOO[        U[
        5      (       a#  UR                  SS5      S:X  a  UR                  nO[        U[        5      (       a  Un UWR                     R                  $ ! [         a     g f = f)N/Typer  r  )
r   rC   r   rr   r   r>   r=  rA   r   r   )rq   r   rr   r(  _is        rt   r&  PdfWriter._get_cloned_page	  s     dJ''dC  d#66B .//DHHWb4IW4T((Bn--B	?555 		s   B/ /
B<;B<annotsc                 (   [        5       n[        U[        5      (       a  [        SUR	                  5       5      nU GHQ  n[        SUR	                  5       5      nUS   S:w  d#  SU;  d  [        SUS   5      S   S:w  d  SU;   Ga
  SU;  a,  UR                  UR                  U 5      R                  5        M|  US   n[        U[        5      (       aK  [        U5      U R                  5       ;   a,  UR                  UR                  U 5      R                  5        M  M  [        S	U5      nU R                  US
   X45      n	U	bL  UR                  U SS9n
[        U	/USS  -   5      U
[        S5      '   UR                  U
R                  5        GMQ  GMT  [        SUS   5      S   n[        U[        5      (       aM  [        U5      U R                  5       ;   a-  UR                  UR                  U 5      R                  5        GM  GM  [        S	U5      nU R                  US
   X45      n	U	c  GM  UR                  U SS9n
[        SU
5      n
[        U	/USS  -   5      [        SU
S   5      [        S5      '   UR                  U
R                  5        GMT     U$ )Nr   r>   r  r  r  r  r  r  r8   r   )r  )r$  r   r  )r  )r8   r   rA   r   r   r   r   r   r   r  r&  rB   )rq   r<  r   rr   r(  outlistananor  r   ancs              rt   r  &PdfWriter._insert_filtered_annotations 
  sN    -fn--&&"3"3"56FB)2==?;CJ7*s?*CI6t<Gc>#%NN399T?#E#EFGA!!S))q6T%=%=%??#NN399T?+M+MN @ !2 11!A$F="%))D
)"KC7BA312;7OC
7 34#NN3+A+AB )
 +SY7=a%%1v!9!9!;;syy'I'IJ < ]A.A--adEBA}!iiGiD"#5s; (ae4 /T;&t,  s'='=>M N rw   nodec                    / nUR                  5       nUR                  SS5      S:X  d  SU;  a;  UR                  SS5      nUb$  UR                  5       nX@R                  XU5      -  nU$ Ub  UR                  5       n[        SUR	                  U5      5      nU R                  [        SUS	   5      X#5      nUc
  [        5       nXe[        S	5      '   SU;   a  U R                  US   X#5      Ul        O/ Ul        [        US	   [        5      (       a  [        UR                  5      S
:  a  UR                  U5        UR                  SS5      nUb  M  U$ )zEExtract outline item entries that are part of the specified page set.r9  r  	/Outlinesr;  /FirstNr=   r   r  r   /Next)r   r=  r  r   _build_outline_itemr&  rC   rB   childsr   r   r   )rq   rC  rr   r(  new_outlineor	  s          rt   r  PdfWriter._get_filtered_outline3
  sD     88GR K/843G88Hd+D(99$vNN"  "((B(B4(HI))$|QwZ*H%X9"A)**W%&t##99$x.%XAH!AH!!G*j99S]Q=N&&q)xx. " rw   c           
      z   [        5       nU R                  U5        [        US   5      U[        S5      '   [	        US   [
        5      (       d`  UR                  b;  SUR                  ;   a+  UR                  S   R                  U 5      U[        S5      '   OUR                  U[        S5      '   UR                  b  [        UR                  R                  SS5      5      U[        S5      '   [        UR                  R                  S[        S5      [        S5      [        S5      /5      5      U[        S5      '   U$ )	Nr;  r  r  r  r  r   /Cg        )rI   re   rH   rB   r   rC   rC  r   r  rD   r=  r8   r@   )rq   r   n_ols      rt   _clone_outlinePdfWriter._clone_outlineS
  s    |%5d8n%EZ!"$w-44yy$):)-4)>)>t)DZ%& -1OOZ()99 %1$))--a2H%IDD!"%0		;s+[-={3?OP&DD!"
 rw   outlinesc                    U H~  nUR                  SS5      S:X  d  SU;  a  UnO?U R                  U5      n[        [        UR	                  5       5      R                  XSU 5        U R                  UR                  US 5        M     g )Nr9  r  rE  r;  )r=  rP  r   rI   r   r  r  rI  )rq   rR  r  r  r   nps         rt   r  "PdfWriter._insert_filtered_outlinej
  su     D xx$3xt7K((.Z!2!2!45BB2tT))$++r4@ rw   c                     g)z"To match the functions from MergerNr  ry   s    rt   r  PdfWriter.closez
  s    rw   c                 n   Uc  U R                  5       nO[        SU5      nSnUb  UR                  U:X  d  UR                  SS 5      U:X  a  U/$ SU;   a;  U R	                  U[        [
        US   5      5      nU(       a  SU;   a  U/U-   $ / U-   $ SU;   a  US-  n[        [        US   5      nOg Ub  M  g g )NrI   r   r;  rF  rG  r   )r  r   r   r=  find_outline_itemrR   rI   )rq   r  r  rK  r  ress         rt   rY  PdfWriter.find_outline_item
  s    
 <%%'A\4(Am$$4554(L8s
q=00$d;(&DC '/1}CC"CC!|QQwZ0# mrw   c                 $    U R                  X5      $ )zB
.. deprecated:: 2.9.0
    Use :meth:`find_outline_item` instead.
)rY  )rq   r  r  s      rt   find_bookmarkPdfWriter.find_bookmark
  s     %%l99rw   c                 6   Uc  0 U l         g[        U[        5      (       a   U R                   [        U5      	 g[        U[
        5      (       a"   U R                   [        UR                  5      	 g[	        S5      e! [         a     gf = f! [         a     gf = f)a  
reset the translation table between reader and the writer object.
late cloning will create new independent objects

:param reader: PdfReader or IndirectObject refering a PdfReader object.
               if set to None or omitted, all tables will be reset.
Nzinvalid parameter {reader})r_   r   r   r   r   rA   r   rP  s     rt   reset_translationPdfWriter.reset_translation
  s     >"$D	**''6
3 //''6::7 899  
  s#   A;  B ;
BB
BB)ro  rx  ry  r\   r_   r^   rj   r]   rf   ro   rk   rX   r  r  r   rp   )r  )rY   rV   )NN)r  )rY   N)r   r  )NNr   r   )NNNN)NNFF/Fit)F)Nrb  )NNTN)NNTr  )r<  
__module____qualname____firstlineno____doc__r   ru   rz   r   r   BaseExceptionr   r   propertyr   r   setterrE   rA   re   r   r   r   r   r   r   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   rr   r  r   r   decimalDecimalr   r   r=   rH   r:   r   r  r  r!  r&  r   r1  r4  OPTIONAL_READ_WRITE_FIELDr   r,   rG  rJ  rQ  rT  rW  rZ  ALL_DOCUMENT_PERMISSIONSr  r5   r  r   r  r   r   r	   r   r  r  r  r  r  r8   r9   r>   r@   rB   rD   rC   r  r  r  r  rI   r  r  r  r  r  r  r  r  r  r#   rQ   r  r  r  r6   r?   r  rO   rT   r'  r/  r3  r8  r<  r?  rD  rG  rK  rN  rv  rz  r~  r  rF   r  r  r  r  r  rP   r  r  r  r  r  r  r  r  rS   r  r  r  r  r  r  r  r  r   r   r   rL   r   rM   r  r.  r   r  r&  r  r  rP  r  r  rR   rY  r]  r`  __static_attributes__r  rw   rt   rV   rV      sw   
&# &#T &#P
%4./% m$% M*	%
 
% E   "U "t " "&y &^ & @D(,;!$^";<; n%; 
	;2	$n,-	$		$ (*	   #~.45   }	 
 
 DN. (*@@  }@ 
	@( (*22  }2 
	2  ')	EE E  }	E
 
E$ ')	<< <  }	<
 
< NRJ#C=J=Ec]J	J.)# )* )0 0%S % @tJ' @ @
 HLe_5=e_	( HL	2e_	25=e_	2		2 ,0,0	( ) 	
 
: ,0,0	<(< )< 	<
 
< 	t["24DD	E < U4k:+M%N SW  & -  -  -D' ' 'PTs PT%U
2C PT PTd	1	1!&sEz!2	1		1 EI// $Hj\4-?$@A/ 
	/> EIAA $Hj\4-?$@AA 
	A& 5	?? S#X? 	?
 
?J 5	GG S#XG 	G
 
G L Lt L	0i 	0D 	0 EIAA $Hj\4-?$@AA 
	A. EICC $Hj\4-?$@AC 
	C" (,(,2J"&#'\ }\  !\  	\ 
 0\  3-\  C=\  
\ |C: C$ C4E$"34 tRx 4 J  49  .
 d3i TW .Z .D . 
1$sCx. 
1T 
1!c3h !D !O3	
O3 
O3b$,^ $, $,L ~ '	 'n '* +  ' ' ''
 '![ !F*+ * AE:>:>48#$j* <=#$ dJ67#$ dJ67	#$
 D*j01#$ 
#$P ;??J
*+? dJ67? 
	?  @D??(0(<?	? >2 ;?:>	V%V dJ67V dJ67	V
 
V 3V* >2LP@+@5=j5I@	@ 3@ >2LP@+@5=j5I@	@ 3@" ;?:>BF!%JOJO 4^S@AJO dJ67	JO
 dJ67JO eE5%$78#=>?JO JO JO JO #JO 
JO` ;?6:

 
 dJ67	

 eUE123
 
 
 
 
 

> ;?6:

 
 dJ67	

 eUE123
 
 
 
 
 

8

%49.+:U4V	" 15$($"9-$ y!$ 
	$<77	7  &*!%	'' c]' #	'
 
'R::#&:	:(#KCt KC KC\ .3	:&*	:		:*CT *Cd *CZ .3	8&*	8		8  )-!%IEIE IE 	IE
 %IE #IE 
IE` )-88 8 	8
 %8 
8( )-OO O 	O
 %O O O 
OH )-RR R 	R
 %R R R 
R&N(:"6 'x
3 'FuZ-C'D F FB&j &T &4	-J 	-4 	- 'Xj1 ' '0 &* & & &  HZ0     " " " "L 6 %Xl3 %G, G4 G 	! 	! 	! %8L1 % %, !l !t ! ! (<0   __\ d  )# )4S> )d )2uZ%?@ Z &"&T;	9:"&	vx
++	,"&R  #GK3{It343 y%S/5c33GcR
3 )U38_eCcM.BDIM
3 3 "%S	5c?(B"CD3 
3j >DTU
 '+)-#GI3- t[)34 sm	
 &  "%S	5c?(B"CD 
 VB7* 7* CO$7* 	7*
 
7*rBGSL!B CO$B 	B
 
B,D#~z:EF CO$ 	
 
.	!*1nd+;&<<=1 1 CO$	1
 1 
k	1f CO$ 	
 
k	@; : 6 ;?	A{#A j.01A dJ67	A
 
A  '+38n {# 
$s)		< >2 '+	:38n	: {#	: 
$s)			: 3	: @D:D)^;<:	: :rw   rV   r   rY   c                 ^   [        U [        5      (       a  U $ [        U [        5      (       a?  [        5       nU R	                  5        H  u  p#[        U5      n[        U5      nXQU'   M!     U$ [        U [        5      (       a/  [        5       nU  H  nUR                  [        U5      5        M     U$ [        U [        5      (       a,  U R                  S5      (       a  [        U 5      $ [        U 5      $ [        U [        [        45      (       a  [        U 5      $ [!        S[#        U 5       S35      e)Nr  z
type(obj)=z! could not be casted to PdfObject)r   rE   r  r>   r  rB   r  r   r8   r   r   
startswithrH   r   r  r@   r2  type)r   r  r  r  name_keycasted_valuer  els           rt   r  r  
  s    #y!!
#t!#))+JC!#H)%0L+8 & 	C		mBJJ~b)* 
	C		>>#c?"#C((	C#u	&	&3!c#DE
 	
rw   r  r  r  r  r  c                 f   [        5       nU b  X[        S5      '   UR                  [        S5      [        U5      05        U(       a  [	        U[
        5      (       a  [        U5      n[        R                  " S5      nUR                  [        S5      [        U Vs/ s H1  n[        [        R                  " U5      R                  U5      5      PM3     sn5      05        U(       d  U(       a?  SnU(       a  US-  nU(       a  US-  nUR                  [        S5      [        U5      05        U$ s  snf )	Nr  r;  z1.00000rN  r   r   r   r  )rI   rB   r`   rJ   r   r   rK   rj  rk  r8   r@   quantizerD   )	r  r  r  r  r  r  preccformat_flags	            rt   r#  r#  
  s    <L)3Z%&x "6u"=	

 eS!!u%Ey)4 +MRSU[!3!<!<T!BCUS#	
 1K1KZ-|K/HIJ Ts   8D.c                   8   ^  \ rS rSrS\S\SS4U 4S jjrSrU =r$ )PdfFileWriteri  r  kwargsrY   Nc                 @   > [        SSS5        [        TU ]  " U0 UD6  g )Nr{  rV   r   )r$   superru   )rq   r  r|  r  s      rt   ru   PdfFileWriter.__init__  s!    $_k7K$)&)rw   r  )r<  rc  rd  re  r
   ru   rn  __classcell__)r  s   @rt   r{  r{    s"    *c *S *T * *rw   r{  )|rg   r  rj  loggingrn  r2  r  rl  r  r   hashlibr   ior   r   r   pathlibr   typesr   typingr	   r
   r   r   r   r   r   r   r   r   r   r   r   r  r   _pager   r   _readerr   	_securityr   r   r   _utilsr   r   r    r!   r"   r#   r$   r%   	constantsr&   r'   r	  r(   r)   rl   r*   rs  r+   r,   r-   r.   r/   r0   r:  r1   ra   r2   rp  r3   rN  r4   r5   genericr6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   	pagerangerL   rM   rN   rO   rP   rQ   rR   rS   rT   	getLoggerr<  r   rl  rm  rV   r   r   r  r  r  r#  r{  r  rw   rt   <module>r     s  <      	      & &       $ +  - -	 	 	 6 . ( ! 5  , , - ( =     0 0   
		8	$ &aL 0A {(: {(:|Q
d38nc3S	AB 
y 
8!dN*+!! ueU*+S$67! 	!
 ! !H*I *rw   