.. index:: 
  !DocumentReader.readField Method
  
.. _id3_document_document_reader_read_field_class_method:

===============================================================================
DocumentReader.readField Method
===============================================================================

Module: :ref:`DocumentReader<id3_document_document_reader_class>`

Definition
----------

Reads a single field in a document.


.. tab-set::

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

      .. code:: Python

        read_field(self, image: DocumentImage, document_name: str, field_name: str) -> TextField

      **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.

          ``field_name`` str
          :guilabel:`in` The name of the field to search.


      **Returns**

        .. line-block::

          :ref:`TextField<id3_document_text_field_class>`
          Read Text in the specified field.

      **Exceptions**

        .. line-block::

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


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

      .. code:: Dart

        TextField readField(DocumentImage image, String? documentName, String? fieldName)

      **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.

          ``fieldName`` String
          :guilabel:`in` The name of the field to search.


      **Returns**

        .. line-block::

          :ref:`TextField<id3_document_text_field_class>`
          Read Text in the specified field.

      **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 TextField ReadField(DocumentImage image, string documentName, string fieldName)

      **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.

          ``fieldName`` string
          :guilabel:`in` The name of the field to search.


      **Returns**

        .. line-block::

          :ref:`TextField<id3_document_text_field_class>`
          Read Text in the specified field.

      **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 TextField readField(DocumentImage image, String documentName, String fieldName) 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.

          ``fieldName`` String
          :guilabel:`in` The name of the field to search.


      **Returns**

        .. line-block::

          :ref:`TextField<id3_document_text_field_class>`
          Read Text in the specified field.

      **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 readField(image: DocumentImage, documentName: String, fieldName: String) throws -> TextField

      **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.

          ``fieldName`` String
          :guilabel:`in` The name of the field to search.


      **Returns**

        .. line-block::

          :ref:`TextField<id3_document_text_field_class>`
          Read Text in the specified field.

      **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_ReadField (
            ID3_DOCUMENT_READER hDocumentReader, 
            ID3_DOCUMENT_IMAGE hImage, 
            const char * documentName, 
            const char * fieldName, 
            ID3_DOCUMENT_TEXT_FIELD hReadText)

      **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.

          ``fieldName`` const char *
          :guilabel:`in` The name of the field to search.

          ``hReadText`` :ref:`ID3_DOCUMENT_TEXT_FIELD<id3_document_text_field_class>`
          :guilabel:`out` Read Text in the specified field.


      **Returns**

        .. line-block::

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


