
    j
                         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
gZ G d d
          ZdS )    )Sequence)PathN)requires_package)AbstractFile   )	read_htmlread_img_as_numpyread_pdfDocumentFilec                       e Zd ZdZededeej                 fd            Z	ede
deej                 fd            Zedee         ez  deej                 fd            Zd	S )
r   z(Read a document from multiple extensionsfilereturnc                     t          |fi |S )a  Read a PDF file

        >>> from doctr.io import DocumentFile
        >>> doc = DocumentFile.from_pdf("path/to/your/doc.pdf")

        Args:
            file: the path to the PDF file or a binary stream
            **kwargs: additional parameters to :meth:`pypdfium2.PdfPage.render`

        Returns:
            the list of pages decoded as numpy ndarray of shape H x W x 3
        r   )clsr   kwargss      R/var/www/html/Carbon-Document/venv/lib/python3.11/site-packages/doctr/io/reader.pyfrom_pdfzDocumentFile.from_pdf   s     '''''    urlc                 \    t          dd           t          |          } | j        |fi |S )a  Interpret a web page as a PDF document

        >>> from doctr.io import DocumentFile
        >>> doc = DocumentFile.from_url("https://www.yoursite.com")

        Args:
            url: the URL of the target web page
            **kwargs: additional parameters to :meth:`pypdfium2.PdfPage.render`

        Returns:
            the list of pages decoded as numpy ndarray of shape H x W x 3
        
weasyprintz`.from_url` requires weasyprint installed.
Installation instructions: https://doc.courtbouillon.org/weasyprint/stable/first_steps.html#installation)r   r   r   )r   r   r   
pdf_streams       r   from_urlzDocumentFile.from_url(   sF     	y	
 	
 	

 s^^
s|J11&111r   filesc                 j    t          |t          t          t          f          r|g}fd|D             S )a  Read an image file (or a collection of image files) and convert it into an image in numpy format

        >>> from doctr.io import DocumentFile
        >>> pages = DocumentFile.from_images(["path/to/your/page1.png", "path/to/your/page2.png"])

        Args:
            files: the path to the image file or a binary stream, or a collection of those
            **kwargs: additional parameters to :meth:`doctr.io.image.read_img_as_numpy`

        Returns:
            the list of pages decoded as numpy ndarray of shape H x W x 3
        c                 *    g | ]}t          |fi S  r	   ).0r   r   s     r   
<listcomp>z,DocumentFile.from_images.<locals>.<listcomp>O   s*    DDDd!$11&11DDDr   )
isinstancestrr   bytes)r   r   r   s     `r   from_imageszDocumentFile.from_images>   s?     ec4/00 	GEDDDDeDDDDr   N)__name__
__module____qualname____doc__classmethodr   listnpndarrayr   r#   r   r   r%   r   r   r   r   r      s        22(L (tBJ7G ( ( ( [( 23 2T"*-= 2 2 2 [2* E 6 E ETXY[YcTd E E E [E E Er   )collections.abcr   pathlibr   numpyr,   doctr.file_utilsr   doctr.utils.common_typesr   htmlr   imager
   pdfr   __all__r   r   r   r   <module>r7      s    % $ $ $ $ $           - - - - - - 1 1 1 1 1 1       $ $ $ $ $ $      
:E :E :E :E :E :E :E :E :E :Er   