.. _document_templates:

==================
Document database
==================

Document templates are files containing information about a specific document type, and needed to detect and read it.
Our documents reference file database can evolve on demand, independently from SDK versions.

.. important::
    
    | Document templates can be downloaded from the following address: 
    | https://cloud.id3.eu/index.php/s/isRrzniF7WZ97bb
      

Document template files
=======================

Document template files have the ``.id3dr`` extension. For modularity reasons, template files are separated by module and models. It increases the number of files, but you can load only those you need.
You must copy those files into your application package, and specify their location in your application's source code. If you wish to reduce the size of your application, we recommend copying only the necessary files.


Reference files are named the following way : ``<document_name>_<model>_X.X.X.V.id3dr``, with : 

- ``X.X.X`` is the SDK version used to generate them. Document references does not exist for each version, please use the latest ones inferior or equal to your SDK version. Other versions will not be supported. *Example : your SDK version is 2.0.3, and the latest document templates inferior might by 2.0.1.*
- ``V`` is an independent document template file version. Please always use the latest for each template.
- The ``<document_name>`` is a unique string used to identify this document in the SDK. It is the one you should use inside SDK functions (for example: in :ref:`id3_document_document_detector_detect_document_by_name_class_method`).
- ``<model>`` contains the SDK AI Model which needs this document template. *Example:* ``detector_2A``

.. note::
    | In each file, one can find both front and back pages of a document.
    | In this case ``<document_name>`` is not corresponding to any document identifier, but is completed by the suffix ``_front`` and ``_back``. The 2 sides are treated like 2 different documents in the SDK, and their identifier key to use includes the suffix !



Loading the document database
=============================

It is recommended to load the document templates on application startup. The :ref:`id3_document_document_library_class` provides methods for loading and unloading document templates in memory.

An example is given below:

.. tab-set::

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

      .. literalinclude:: /../samples/sample.py
        :language: python
        :start-after: [loading_document_templates]
        :end-before: [loading_document_templates]
        :dedent: 4



See also
========
- :ref:`id3_document_document_library_class`
- :ref:`id3_document_document_library_load_document_template_class_method`