.. index:: 
  !DocumentReader.readDocument Method
  
.. _id3_document_document_reader_read_document_class_method:

===============================================================================
DocumentReader.readDocument Method
===============================================================================

Module: :ref:`DocumentReader<id3_document_document_reader_class>`

Definition
----------

Reads all the fields in a document.


.. tab-set::

    .. tab-item:: Python
      :sync: Python

      .. code:: Python

        read_document(self, image: DocumentImage, document_name: str) -> TextFieldList

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``document_name`` str
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.


      **Returns**

        .. line-block::

          :ref:`TextFieldList<id3_document_text_field_list_class>`
          A list of all the text fields read in the document.

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


    .. tab-item:: Dart
      :sync: Dart

      .. code:: Dart

        TextFieldList readDocument(DocumentImage image, String? documentName)

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``documentName`` String
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.


      **Returns**

        .. line-block::

          :ref:`TextFieldList<id3_document_text_field_list_class>`
          A list of all the text fields read in the document.

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


    .. tab-item:: C#
      :sync: C#

      .. code:: C#

        public TextFieldList ReadDocument(DocumentImage image, string documentName)

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``documentName`` string
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.


      **Returns**

        .. line-block::

          :ref:`TextFieldList<id3_document_text_field_list_class>`
          A list of all the text fields read in the document.

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


    .. tab-item:: Java
      :sync: Java

      .. code:: Java

        public TextFieldList readDocument(DocumentImage image, String documentName) throws DocumentException

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``documentName`` String
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.


      **Returns**

        .. line-block::

          :ref:`TextFieldList<id3_document_text_field_list_class>`
          A list of all the text fields read in the document.

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


    .. tab-item:: Swift
      :sync: Swift

      .. code:: Swift

        public func readDocument(image: DocumentImage, documentName: String) throws -> TextFieldList

      **Parameters**

        .. line-block::

          ``image`` :ref:`DocumentImage<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``documentName`` String
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.


      **Returns**

        .. line-block::

          :ref:`TextFieldList<id3_document_text_field_list_class>`
          A list of all the text fields read in the document.

      **Exceptions**

        .. line-block::

          :ref:`DocumentException<id3_document_document_exception>`
          An error has occurred during Document Library execution.


    .. tab-item:: C
      :sync: C

      .. code:: C

        int id3DocumentReader_ReadDocument (
            ID3_DOCUMENT_READER hDocumentReader, 
            ID3_DOCUMENT_IMAGE hImage, 
            const char * documentName, 
            ID3_DOCUMENT_TEXT_FIELD_LIST hReadTexts)

      **Parameters**

        .. line-block::

          ``hDocumentReader`` :ref:`ID3_DOCUMENT_READER<id3_document_document_reader_class>`
          :guilabel:`in` Handle to the DocumentReader object.

          ``hImage`` :ref:`ID3_DOCUMENT_IMAGE<id3_document_document_image_class>`
          :guilabel:`in` The image that contains the document. Must be a realigned BGR image of the document.

          ``documentName`` const char *
          :guilabel:`in` The name of the document to be searched. Must be a key loaded in DocumentLibrary.

          ``hReadTexts`` :ref:`ID3_DOCUMENT_TEXT_FIELD_LIST<id3_document_text_field_list_class>`
          :guilabel:`out` A list of all the text fields read in the document.


      **Returns**

        .. line-block::

          ``int``
          An error code.
          See :ref:`id3DocumentError<id3_document_document_error_enum>` file for the list of possible error codes.


