# SMILES to PDF And Back

PDF Parsing is going to be handling by a separate package called MolPDF. It has pretty much a fixed template and is used for handling data distribution quickly so we can get a general feel of a molecule list.&#x20;

{% embed url="<https://github.com/Sulstice/molpdf>" %}

The philosophy is very simple. We don't really need a template but a simple PDF document to transfer data quickly especially in the case of a supplementary information. We use the meta data stored in the PDF to store the SMILES in accordance with the images. That way it makes it easier to mine the data quickly into a python object.&#x20;

**Imports**

```
from global_chem import GlobalChem
from global_chem_extensions import GlobalChemExtensions

gc = GlobalChem()
cheminformatics = GlobalChemExtensions().cheminformatics()
```

**SMILES to PDF**

{% tabs %}
{% tab title="Code" %}

```
smiles_list = list(gc.get_node_smiles('pihkal').values())

cheminformatics.smiles_to_pdf(
    smiles=smiles_list,
    labels = [],
    file_name = 'molecules.pdf',
    include_failed_smiles = True,
    title = 'MY MOLECULES',
)
```

{% endtab %}

{% tab title="Output" %}

```
Method: 'generate' Time: 4.98 seconds
```

{% endtab %}
{% endtabs %}

**PDF to SMILES**

{% tabs %}
{% tab title="Code" %}

```
molecules = cheminformatics.pdf_to_smiles(
    'molecules.pdf',
)

print (len(molecules))
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://globalchem.gitbook.io/globalchem-your-chemical-graph-network/cheminformatics/smiles-to-pdf-and-back.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
