.. include:: ../substitutions

.. oe:namespace:: OEDepict

.. meta::
   :keywords: OERenderMoleculeToString

.. _OEDepict_OERenderMoleculeToString:


.. oe:function:: OERenderMoleculeToString



   .. list-table:: **The overloaded versions of the OERenderMoleculeToString function**
      :widths: 100 200
      :header-rows: 1

      * - Link
        - Description

      * - :ref:`OERenderMoleculeToString(ext, disp)<api_OERenderMoleculeToString_disp>`
        - writes a molecule display into a string (byte array)

      * - :ref:`OERenderMoleculeToString(ext, mol)<api_OERenderMoleculeToString_disp>`
        - writes a molecule into a string (byte array) using the **default** depiction style

.. _api_OERenderMoleculeToString_disp:

   .. oe:api::

      std::string OERenderMoleculeToString(const std::string& ext,
                                           const OE2DMolDisplay& disp,
                                           bool clearbackground = true)

   Writes a molecule display into a string.

   *ext*
      The extension which determine the type of the image.

   *disp*
      The :ref:`OE2DMolDisplay <OEDepict_OE2DMolDisplay>` object that holds the
      data necessary to depict the molecule with which it is
      initialized.

   *clearbackground*
      Determines whether or not the image is cleared
      (by calling :oe:meth:`OEDepict::OEImageBase::Clear` method)
      prior to the molecule rendering.

   .. seealso::

      * :oe:func:`OEDepict::OEIsRegisteredImageFile` function


   .. ################################################################

.. _api_OERenderMoleculeToString_mol:

   .. oe:api::

      std::string OERenderMoleculeToString(const std::string& ext,
                                           const OEChem::OEMolBase& mol,
                                           bool clearbackground = true)

   Writes a molecule into a string using the **default** depiction style.

   *ext*
      The extension which determine the type of the image.

   *mol*
      The molecule being rendered.

   *clearbackground*
      Determines whether or not the image is cleared
      (by calling :oe:meth:`OEDepict::OEImageBase::Clear` method)
      prior to the molecule rendering.

   **Example:**

   .. oe:source:: RenderMoleculeToString.py
      :language: python
      :noindent:
      :frag:     SNIPPET-RENDER-MOL-TO-STRING

   .. oe:source:: RenderMoleculeToString.cpp
      :language: c++
      :noindent:
      :frag:     SNIPPET-RENDER-MOL-TO-STRING

   .. oe:source:: RenderMoleculeToString.java
      :language: java
      :noindent:
      :frag:     SNIPPET-RENDER-MOL-TO-STRING

   .. oe:source:: RenderMoleculeToString.cs
      :language: csharp
      :noindent:
      :frag:     SNIPPET-RENDER-MOL-TO-STRING

   .. oe:language:: python

      .. note::

         In **Python 3** the :oe:func:`OEDepict::OERenderMoleculeToString`
         function returns ``bytes``.

   .. seealso::

      * :oe:func:`OEDepict::OEIsRegisteredImageFile` function

      .. oe:language:: python

         * :oe:func:`OEDepict::OERenderMoleculeToBytes` function
