
    Ngg                     V   d Z ddlZddlZddlZddlZddlZddlmZ ddlm	Z	 ddl
ZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ  ej        e          Z G d
 dej                  Z  G d dej                  Z! G d dej                  Z"d Z# e	dd          Z$dS ))PdfDocument
PdfFormEnv
PdfXObjectPdfOutlineItem    N)Path)
namedtuple)PDFIUM_INFO)PdfiumError)PdfPage)	PdfObject)PdfAttachmentc                   \    e Zd ZdZd' fd	Z fdZed             Zed             Z	d Z
d	 Zd
 Zd Zed             Zd(dZd Zd Zd Zdej        fdZej        fdZd Zd ZdZd)dZd Zd Zd Zd Z d Z!d(dZ"d Z#d*dZ$d Z%d  Z&d! Z'd" Z(	 	 	 	 d+d%Z)e*j+        ddddfd&Z+ xZ,S ),r   a  
    Document helper class.
    
    Parameters:
        input_data (str | pathlib.Path | bytes | ctypes.Array | typing.BinaryIO | FPDF_DOCUMENT):
            The input PDF given as file path, bytes, ctypes array, byte buffer, or raw PDFium document handle.
            A byte buffer is defined as an object that implements ``seek() tell() read() readinto()``.
        password (str | None):
            A password to unlock the PDF, if encrypted. Otherwise, None or an empty string may be passed.
            If a password is given but the PDF is not encrypted, it will be ignored (as of PDFium 5418).
        autoclose (bool):
            Whether byte buffer input should be automatically closed on finalization.
    
    Raises:
        PdfiumError: Raised if the document failed to load. The exception message is annotated with the reason reported by PDFium.
        FileNotFoundError: Raised if an invalid or non-existent file path was given.
    
    Hint:
        * :func:`len` may be called to get a document's number of pages.
        * Looping over a document will yield its pages from beginning to end.
        * Pages may be loaded using list index access.
        * The ``del`` keyword and list index access may be used to delete pages.
    
    Attributes:
        raw (FPDF_DOCUMENT):
            The underlying PDFium document handle.
        formenv (PdfFormEnv | None):
            Form env, if the document has forms and :meth:`.init_forms` was called.
    NFc                    t          |t                    rt          |          }t          |t                    rI|                                                                }|                                st          |          || _        || _        || _	        g | _
        g | _        d | _        t          | j        t          j                  r| j        | _        nIt!          | j        | j        | j	                  \  | _        }}| xj
        |z  c_
        | xj        |z  c_        t#                                          t&          j        | j
        | j                   d S N)
isinstancestrr   
expanduserresolveis_fileFileNotFoundError_input	_password
_autoclose_data_holder_data_closerformenvpdfium_cFPDF_DOCUMENTraw	_open_pdfsuper__init__r   _close_impl)selfinputpassword	autocloseto_holdto_close	__class__s         W/var/www/html/ai-engine/env/lib/python3.11/site-packages/pypdfium2/_helpers/document.pyr"   zPdfDocument.__init__9   s2   eS!! 	 KKEeT"" 	/$$&&..00E==?? /'...!# dk8#9:: 	*{DHH*3DKQUQ`*a*a'DHgx()0$2CTEVWWWWW    c                 
   t          | j        t                    r"t          t	          | j                            }nt          | j        t
                    r&dt          t          | j                             d}nYt          | j        t          j	                  r&dt          t          | j                             d}nt          | j                  }t                                                      d d          d| dS )Nz<bytes object at >z<FPDF_DOCUMENT at z from )r   r   r   reprr   byteshexidr   r   r!   __repr__)r$   input_rr*   s     r+   r4   zPdfDocument.__repr__U   s    dk4(( 	(C,,..GGU++ 	(A#boo*>*>AAAGGX%;<< 	(B3r$++?+?BBBGG4;''G''""$$SbS);;;;;;r,   c                     d S r    r$   s    r+   parentzPdfDocument.parenta   s    tr,   c                     t          j        |            |D ]}t          |           |D ]}|                                 |                                 |                                 d S r   )r   FPDF_CloseDocumentr3   closeclear)r   data_holderdata_closerdatas       r+   r#   zPdfDocument._close_implf   sw    #C((( 	 	DtHHHH 	 	DJJLLLLr,   c                 *    t          j        |           S r   )r   FPDF_GetPageCountr8   s    r+   __len__zPdfDocument.__len__q   s    )$///r,   c              #   \   K   t          t          |                     D ]}| |         V  d S r   )rangelenr$   is     r+   __iter__zPdfDocument.__iter__t   s<      D		## 	 	Aq'MMMM	 	r,   c                 ,    |                      |          S r   )get_pagerG   s     r+   __getitem__zPdfDocument.__getitem__x   s    }}Qr,   c                 0    |                      |           d S r   )del_pagerG   s     r+   __delitem__zPdfDocument.__delitem__{   s    ar,   c                 >    t          j                    } | |          S )zJ
        Returns:
            PdfDocument: A new, empty document.
        )r   FPDF_CreateNewDocument)clsnew_pdfs     r+   newzPdfDocument.new   s      133s7||r,   c                    |                                  }|t          j        k    s| j        rdS dt          j        v r/t          j        dk    rt          j        dk    rt          d          |sbdt          j        v r?t          j	        d          }t          j
        d	d
t          j        |                    }nt          j
        d	          }t          j        | |          }|st          d|  d          t          |||           | _        |                     | j                   |t          j        t          j        fv rdt          j        v rgt          j        |           }|sOt          j                    }t*                              dt.          j                            |                      dS dS t*                              d           dS dS )a  
        Initialize a form env, if the document has forms. If already initialized, nothing will be done.
        See the :attr:`formenv` attribute.
    
        Attention:
            If form rendering is desired, this method shall be called immediately after document construction, before getting document length or page handles.
        
        Parameters:
            config (FPDF_FORMFILLINFO | None):
                Custom form config interface to use (optional).
        NV8sourcebuildi-  z@V8 enabled pdfium-binaries builds <= 5677 crash on init_forms().XFA   )version   F)rZ   xfa_disabledm_pJsPlatformz*Initializing form env failed for document .zFPDF_LoadXFA() failed with zinit_forms() called on XFA pdf, but this pdfium binary was compiled without XFA support.
Run `PDFIUM_PLATFORM=auto-v8 pip install -v pypdfium2 --no-binary pypdfium2` to get a build with XFA support.)get_formtyper   FORMTYPE_NONEr   r	   flagsoriginbuildRuntimeErrorIPDF_JSPLATFORMFPDF_FORMFILLINFOctypespointerFPDFDOC_InitFormFillEnvironmentr
   r   _add_kidFORMTYPE_XFA_FULLFORMTYPE_XFA_FOREGROUNDFPDF_LoadXFAFPDF_GetLastErrorloggerwarningpdfium_iXFAErrorToStrget)r$   configformtypejs_platformr   okerrs          r+   
init_formszPdfDocument.init_forms   s    $$&&x----F ;$$$);})L)LQ\QbfjQjQjabbb 	?)))&6qAAA!3AEagaop{a|a|}}}!3A>>>6tVDD 	TR4RRRSSS!#vt44dl###2H4TUUU)))*400 d"466CNN#bAWA[A[\_A`A`#b#bcccccd d D     VUr,   c                 *    t          j        |           S )z
        Returns:
            int: PDFium form type that applies to the document (:attr:`FORMTYPE_*`).
            :attr:`FORMTYPE_NONE` if the document has no forms.
        )r   FPDF_GetFormTyper8   s    r+   r_   zPdfDocument.get_formtype   s     (...r,   c                 *    t          j        |           S )zV
        Returns:
            int: Page displaying mode (:attr:`PAGEMODE_*`).
        )r   FPDFDoc_GetPageModer8   s    r+   get_pagemodezPdfDocument.get_pagemode   s    
 +D111r,   c                 D    t          t          j        |                     S )zm
        Returns:
            bool: Whether the document is tagged (cf. PDF 1.7, 10.7 "Tagged PDF").
        )boolr   FPDFCatalog_IsTaggedr8   s    r+   	is_taggedzPdfDocument.is_tagged   s    
 X2488:::r,   c                    t          |t          t          f          rt          |d          d}}n-t	          j        |d          r|d}}nt          d| d          	 | t	          j        |          |f}|t          j	        | nt          j
        g ||R  }|st          d          	 |r|                                 dS dS # |r|                                 w w xY w)	a
  
        Save the document at its current state.
        
        Parameters:
            dest (str | pathlib.Path | io.BytesIO):
                File path or byte buffer the document shall be written to.
            version (int | None):
                The PDF version to use, given as an integer (14 for 1.4, 15 for 1.5, ...).
                If None (the default), PDFium will set a version automatically.
            flags (int):
                PDFium saving flags (defaults to :attr:`FPDF_NO_INCREMENTAL`).
        wbTwFzCannot save to ''NzFailed to save document.)r   r   r   openrq   	is_buffer
ValueErrorget_bufwriterr   FPDF_SaveAsCopyFPDF_SaveWithVersionr
   r<   )r$   destrZ   ra   buffer
need_closesaveargsrw   s           r+   savezPdfDocument.save   s    dS$K(( 	9!%dD!1!14JFFc** 	9!%uJFF7777888	h4V<<eDH8?)844XMjM~ltM~v}M~M~M~B >!"<===>   z s   AC Cc                     t          j        | |dd          }t          j        |          }t          j        | |||           |j        d|dz
           S )a  
        Parameters:
            type (int):
                The identifier type to retrieve (:attr:`FILEIDTYPE_*`), either permanent or changing.
                If the file was updated incrementally, the permanent identifier stays the same,
                while the changing identifier is re-calculated.
        Returns:
            bytes: Unique file identifier from the PDF's trailer dictionary.
            See PDF 1.7, Section 14.4 "File Identifiers".
        Nr   r[   )r   FPDF_GetFileIdentifierrg   create_string_bufferr   )r$   typen_bytesr   s       r+   get_identifierzPdfDocument.get_identifier   sV     1$dAFF,W55'dFGDDDz*719*%%r,   c                 h    t          j                    }t          j        | |          }|sdS |j        S )z
        Returns:
            int | None: The PDF version of the document (14 for 1.4, 15 for 1.5, ...),
            or None if the document is new or its version could not be determined.
        N)rg   c_intr   FPDF_GetFileVersionvalue)r$   rZ   rw   s      r+   get_versionzPdfDocument.get_version  s6     ,..)$88 	4}r,   c                     |dz                        d          }t          j        | |dd          }t          j        |          }t          j        | |||           |j        d|dz
                               d          S )z
        Returns:
            str: Value of the given key in the PDF's metadata dictionary.
            If the key is not contained, an empty string will be returned.
         utf-8Nr   r[   	utf-16-le)encoder   FPDF_GetMetaTextrg   r   r   decode)r$   keyenc_keyr   r   s        r+   get_metadata_valuezPdfDocument.get_metadata_value  s{     <''00+D'4CC,W55!$AAAz*719*%,,[999r,   )TitleAuthorSubjectKeywordsCreatorProducerCreationDateModDatec                 n      fd j         D             }|rd |                                D             }|S )z
        Get the document's metadata as dictionary.
        
        Parameters:
            skip_empty (bool):
                If True, skip items whose value is an empty string.
        Returns:
            dict: PDF metadata.
        c                 <    i | ]}|                     |          S r7   )r   ).0kr$   s     r+   
<dictcomp>z1PdfDocument.get_metadata_dict.<locals>.<dictcomp>,  s)    NNNaAt..q11NNNr,   c                     i | ]
\  }}|||S r7   r7   )r   r   vs      r+   r   z1PdfDocument.get_metadata_dict.<locals>.<dictcomp>.  s#    ???AQ?1???r,   )METADATA_KEYSitems)r$   
skip_emptymetadatas   `  r+   get_metadata_dictzPdfDocument.get_metadata_dict"  sM     ONNN4;MNNN 	@??)9)9???Hr,   c                 *    t          j        |           S )zY
        Returns:
            int: The number of embedded files in the document.
        )r   FPDFDoc_GetAttachmentCountr8   s    r+   count_attachmentszPdfDocument.count_attachments2  s    
 24888r,   c                 v    t          j        | |          }|st          d| d          t          ||           S )z]
        Returns:
            PdfAttachment: The attachment at *index* (zero-based).
        z"Failed to get attachment at index r^   )r   FPDFDoc_GetAttachmentr
   r   )r$   indexraw_attachments      r+   get_attachmentzPdfDocument.get_attachment:  sI    
 "7eDD 	MK5KKKLLL^T222r,   c                     |dz                        d          }t          j        |t          j                  }t          j        | |          }|st          d| d          t          ||           S )aN  
        Add a new attachment to the document. It may appear at an arbitrary index (as of PDFium 5418).
        
        Parameters:
            name (str):
                The name the attachment shall have. Usually a file name with extension.
        Returns:
            PdfAttachment: Handle to the new, empty attachment.
        r   r   z!Failed to create new attachment 'z'.)r   rg   castr   FPDF_WIDESTRINGFPDFDoc_AddAttachmentr
   r   )r$   nameenc_nameenc_name_ptrr   s        r+   new_attachmentzPdfDocument.new_attachmentE  st     6M))+66{8X-EFF!7lKK 	LJ$JJJKKK^T222r,   c                 Z    t          j        | |          }|st          d| d          dS )a  
        Unlink the attachment at *index* (zero-based).
        It will be hidden from the viewer, but is still present in the file (as of PDFium 5418).
        Following attachments shift one slot to the left in the array representation used by PDFium's API.
        
        Handles to the attachment in question received from :meth:`.get_attachment`
        must not be accessed anymore after this method has been called.
        z%Failed to delete attachment at index r^   N)r   FPDFDoc_DeleteAttachmentr
   )r$   r   rw   s      r+   del_attachmentzPdfDocument.del_attachmentW  sE     .tU;; 	PNeNNNOOO	P 	Pr,   c                     t          j        | |          }|st          d          t          || | j                  }| j        r5t          j        || j                   | j                            |           n|                     |           |S )a   
        Returns:
            PdfPage: The page at *index* (zero-based).
        Note:
            This calls ``FORM_OnAfterLoadPage()`` if the document has an active form env.
            The form env must not be closed before the page is closed!
        zFailed to load page.)r   FPDF_LoadPager
   r   r   FORM_OnAfterLoadPagerj   )r$   r   raw_pagepages       r+   rK   zPdfDocument.get_pagef  s     )$66 	64555xt|44< 	 )$===L!!$''''MM$r,   c                     |t          |           }t          j        | |||          }t          || d          }|                     |           |S )a  
        Insert a new, empty page into the document.
        
        Parameters:
            width (float):
                Target page width (horizontal size).
            height (float):
                Target page height (vertical size).
            index (int | None):
                Suggested zero-based index at which the page shall be inserted.
                If None or larger that the document's current last index, the page will be appended to the end.
        Returns:
            PdfPage: The newly created page.
        N)rF   r   FPDFPage_Newr   rj   )r$   widthheightr   r   r   s         r+   new_pagezPdfDocument.new_page}  sR     =IIE(ueVDDxt,,dr,   c                 0    t          j        | |           dS )z:
        Remove the page at *index* (zero-based).
        N)r   FPDFPage_Delete)r$   r   s     r+   rN   zPdfDocument.del_page  s    
 	 u-----r,   c                 F   |t          |           }t          |t                    r+t          j        | ||                    d          |          }n>d}d}|r t          |          }t          j        |z  | }t          j        | ||||          }|st          d          dS )a.  
        Import pages from a foreign document.
        
        Parameters:
            pdf (PdfDocument):
                The document from which to import pages.
            pages (list[int] | str | None):
                The pages to include. It may either be a list of zero-based page indices, or a string of one-based page numbers and ranges.
                If None, all pages will be included.
            index (int):
                Zero-based index at which to insert the given pages. If None, they are appended to the end of the document.
        Nasciir   zFailed to import pages.)
rF   r   r   r   FPDF_ImportPagesr   rg   r   FPDF_ImportPagesByIndexr
   )r$   pdfpagesr   rw   
page_countc_pagess          r+   import_pageszPdfDocument.import_pages  s     =IIEeS!! 	Y*4ell76K6KUSSBBJG > ZZ
!<*4u=1$WjRWXXB 	97888	9 	9r,   c                     t          j                    }t          j        | ||          }|st          d          |j        |j        fS )z
        Returns:
            (float, float): Width and height in PDF canvas units of the page at *index* (zero-based).
        z!Failed to get page size by index.)r   FS_SIZEFFPDF_GetPageSizeByIndexFr
   r   r   )r$   r   sizerw   s       r+   get_page_sizezPdfDocument.get_page_size  sM    
  "".tUDAA 	CABBB
DK((r,   c                     t          j        | |dd          }t          j        |          }t          j        | |||           |j        d|dz
                               d          S )z
        Returns:
            str: Label of the page at *index* (zero-based).
            (A page label is essentially an alias that may be displayed instead of the page number.)
        Nr   r[   r   )r   FPDF_GetPageLabelrg   r   r   r   )r$   r   r   r   s       r+   get_page_labelzPdfDocument.get_page_label  sd     ,T5$BB,W55"4@@@z*719*%,,[999r,   c                     t          j        || |          }|t          d| d          t          ||          }|                     |           |S )a_  
        Capture a page as XObject and attach it to a document's resources.
        
        Parameters:
            index (int):
                Zero-based index of the page.
            dest_pdf (PdfDocument):
                Target document to which the XObject shall be added.
        Returns:
            PdfXObject: The page as XObject.
        Nz Failed to capture page at index z as FPDF_XOBJECT.r   r   )r   FPDF_NewXObjectFromPager
   r   rj   )r$   r   dest_pdfraw_xobjectxobjects        r+   page_as_xobjectzPdfDocument.page_as_xobject  sa     6xuMMYYYYZZZ(;;;gr,   c           	      |   t          j        |d d          }t          j        |          }t          j        |||           |j        d |dz
                               d          }t          j        |          }|dk     rdn	|dk    rd nd}t          |          }t          j        | |          }	t          j	        | |	          }
|
dk    rd }
t          j
                    }t          j        dz              }t          j        |	||          }t          |          d |j                 }t          |||||
||          S )	Nr   r[   r   TFr/      )leveltitle	is_closedn_kids
page_index	view_modeview_pos)r   FPDFBookmark_GetTitlerg   r   r   r   FPDFBookmark_GetCountabsFPDFBookmark_GetDestFPDFDest_GetDestPageIndexc_ulongFS_FLOATFPDFDest_GetViewlistr   r   )r$   bookmarkr   r   r   r   countr   r   r   r   n_paramsr   r   s                 r+   _get_bookmarkzPdfDocument._get_bookmark  sA   04CC,W55&xAAA
:GAI:&--k:: .x88!AIIDD5A::445	U,T8<<7dCC
J>##%),,-dHhGG	>>/8>/2!#!
 
 
 	
r,      r   c              #     K   |t                      }t          j        | |          }|rt          j        |j                  }||v rt                              d           dS |                    |           | 	                    ||          V  ||dz
  k     r"| 
                    |||dz   |          E d{V  t          j        | |          }|dS dS )a  
        Iterate through the bookmarks in the document's table of contents.
        
        Parameters:
            max_depth (int):
                Maximum recursion depth to consider.
        Yields:
            :class:`.PdfOutlineItem`: Bookmark information.
        NzPA circular bookmark reference was detected whilst parsing the table of contents.   )	max_depthr9   r   seen)setr   FPDFBookmark_GetFirstChildrg   	addressofcontentsro   rp   addr  get_tocFPDFBookmark_GetNextSibling)r$   r  r9   r   r  r  addresss          r+   r  zPdfDocument.get_toc  s"     " <55D6tVDD 	L&x'899G$qrrr!!!$$Xu55555y{""<< )%!AI	 (           ;D(KKH%  	L 	L 	L 	L 	Lr,   c              +     K   t          j        dt                     |s&d t          t	          |                     D             }|D ]B} || |         fi |}	|r" ||	          |	                                fV  5 ||	          V  CdS )a  
        .. deprecated:: 4.19
           This method will be removed with the next major release due to serious issues rooted in the original API design. Use :meth:`.PdfPage.render()` instead.
           *Note that the CLI provides parallel rendering using a proper caller-side process pool with inline saving in rendering jobs.*
        
        .. versionchanged:: 4.25
           Removed the original process pool implementation and turned this into a wrapper for linear rendering, due to the serious conceptual issues and possible memory load escalation, especially with expensive receiving code (e.g. PNG encoding) or long documents. See the changelog for more info
        zThe document-level pdf.render() API is deprecated and uncored due to serious issues in the original concept. Use page.render() and a caller-side loop or process pool instead.)categoryc                     g | ]}|S r7   r7   )r   rH   s     r+   
<listcomp>z&PdfDocument.render.<locals>.<listcomp>M  s    888!A888r,   N)warningswarnDeprecationWarningrE   rF   get_info)
r$   	converterrendererpage_indices	pass_infon_processesmk_formconfigkwargsrH   bitmaps
             r+   renderzPdfDocument.render7  s      & 	  G  Rd  	e  	e  	e  	e 	988uSYY'7'7888L 	( 	(AXd1g0000F ( y((&//*;*;<<<<<i''''''	( 	(r,   )NFr   )F)NN)r  Nr   N)-__name__
__module____qualname____doc__r"   r4   propertyr9   staticmethodr#   rC   rI   rL   rO   classmethodrT   ry   r_   r~   r   r   FPDF_NO_INCREMENTALr   FILEIDTYPE_PERMANENTr   r   r   r   r   r   r   r   r   rK   r   rN   r   r   r   r   r  r  r   r%  __classcell__r*   s   @r+   r   r      s        <X X X X X X8	< 	< 	< 	< 	<   X   \0 0 0            [- - - -b/ / /2 2 2; ; ; "&X-I    > #+"? & & & &"
 
 

: 
: 
: qM    9 9 93 3 33 3 3$P P P  .   0. . .9 9 9 9>	) 	) 	)	: 	: 	:  ,
 
 
H (L (L (L (L\ ~ ( ( ( ( ( ( ( (r,   r   c                   N     e Zd ZdZ fdZed             Zed             Z xZ	S )r   aM  
    Form environment helper class.
    
    Attributes:
        raw (FPDF_FORMHANDLE):
            The underlying PDFium form env handle.
        config (FPDF_FORMFILLINFO):
            Accompanying form configuration interface, to be kept alive.
        pdf (PdfDocument):
            Parent document this form env belongs to.
    c                     |||c| _         | _        | _        t                                          t
          j        | j        | j                   d S r   )r   rt   r   r!   r"   r   r#   )r$   r   rt   r   r*   s       r+   r"   zPdfFormEnv.__init__c  sB    *-vs'$+tx/dhGGGGGr,   c                     | j         S r   r   r8   s    r+   r9   zPdfFormEnv.parentg  	    xr,   c                 Z    t          j        |            t          |           d |_        d S r   )r   FPDFDOC_ExitFormFillEnvironmentr3   r   )r   rt   r   s      r+   r#   zPdfFormEnv._close_implk  s)    0555
6


r,   )
r&  r'  r(  r)  r"   r*  r9   r+  r#   r/  r0  s   @r+   r   r   V  s}        
 
H H H H H   X   \    r,   r   c                   >     e Zd ZdZ fdZed             Zd Z xZS )r   z
    XObject helper class.
    
    Attributes:
        raw (FPDF_XOBJECT): The underlying PDFium XObject handle.
        pdf (PdfDocument): Reference to the document this XObject belongs to.
    c                 |    ||c| _         | _        t                                          t          j                   d S r   )r   r   r!   r"   r   FPDF_CloseXObject)r$   r   r   r*   s      r+   r"   zPdfXObject.__init__{  s4     #$(344444r,   c                     | j         S r   r4  r8   s    r+   r9   zPdfXObject.parent  r5  r,   c                 V    t          j        |           }t          || j                  S )a  
        Returns:
            PdfObject: An independent page object representation of the XObject.
            If multiple page objects are created from one XObject, they share resources.
            Page objects created from an XObject remain valid after the XObject is closed.
        r   )r   FPDF_NewFormObjectFromXObjectr   r   )r$   raw_pageobjs     r+   as_pageobjectzPdfXObject.as_pageobject  s3     <TBB(
 
 
 	
r,   )	r&  r'  r(  r)  r"   r*  r9   r?  r/  r0  s   @r+   r   r   r  sl         5 5 5 5 5   X
 
 
 
 
 
 
r,   r   c                    d\  }}||dz                        d          }t          | t                    r9t          j        t          |           dz                        d          |          }nt          | t          t          j        f          r't          j	        | t          |           |          }| f}nlt          j        | d          r2t          j        |           \  }}|r| f}t          j        ||          }n%t          dt!          |           j         d          t          j        |          dk     rCt          j                    }t)          dt          j                            |           d	          |||fS )
N)r7   r7   r   r   rzInvalid input type 'r   r
  z!Failed to load document (PDFium: z).)r   r   r   r   FPDF_LoadDocumentr   r1   rg   ArrayFPDF_LoadMemDocument64rF   rq   r   get_bufreaderFPDF_LoadCustomDocument	TypeErrorr   r&  rB   rn   r
   
ErrorToStrrs   )
input_datar&   r'   r(   r)   r   	bufaccesserr_codes           r+   r    r      sw   GXVO++G44*d## M(#j//&*@)H)H)Q)QS[\\	J 5	6	6 	M-j#j//8TT.		J	,	, M%3J??	7 	&"~H.y(CCKtJ/?/?/HKKKLLL!#&&**-//ch>Q>U>UV^>_>_cccddd!!r,   r   z:level title is_closed n_kids page_index view_mode view_pos)%__all__osrg   logginginspectr  pathlibr   collectionsr   multiprocessingmppypdfium2.rawr   r   pypdfium2.internalinternalrq   pypdfium2.versionr	   pypdfium2._helpers.miscr
   pypdfium2._helpers.pager   pypdfium2._helpers.pageobjectsr   pypdfium2._helpers.attachmentr   	getLoggerr&  ro   AutoCloseabler   r   r   r    r   r7   r,   r+   <module>r^     s   H 				           " " " " " "                 % % % % % % ) ) ) ) ) ) / / / / / / + + + + + + 4 4 4 4 4 4 7 7 7 7 7 7		8	$	$y( y( y( y( y(8) y( y( y(x    ((   8
 
 
 
 
(( 
 
 
>" " "6 ,.jkk r,   