# PDF Generation
This page is dedicated to AIKP Developers which would like to know how and what ocli-core tools to use to generate a PDF Report.
## Templates
The recommended way when trying to generate a PDF is to use a template. Currently `ocli-core` has built-in functionality for working with Jinja templates, but the developer is free to use any other method.
### Jinja Templates
Jinja2 is a powerful templating engine for Python, that allows you to generate dynamic HTML (or any text-based format) by mixing static content with Python-like logic. Think of it as the bridge between your data and your presentation.
Here is an example:
```html
Report for ROI {{roi_name}}; task: {{task_name}}
Report for ROI {{roi_name}}; task: {{task_name}}
Here are some example statistics:
{% for stat in stats %}
{{stat}}
{% endfor %}
```
Currently `ocli-core` has a built-in helper that allows the user to load a jinja template: `ocli.core.pdf_utils.load_jtemplate`
##### Function signature
```py
def load_jtemplate(path : str, searchpath : str = "/") -> Template | None:
```
##### Parameters
- `path` - path of the jinja template
- `searchpath` - a path, or list of paths, to the directory that contains the templates.
##### How to use
```py
from ocli.core.pdf_utils import load_jtemplate
template = load_jtemplate(path="/some/path", searchpath="/some/directory")
```
##### How to populate the template
After successfully importing a template, in order to generate the final html content, we would have to populate the template by passing the following variables: `roi_name`, `task_name` and `stats`.
```py
html = template.render(roi_name="Some roi", task_name="Some task", stats=['First statistic'])
```
#### Exporting the content to a PDF
After successfully populating the template with the desired values, the user can export the html content as a PDF by using another helper function: `ocli.core.pdf_utils.load_jtemplate`
##### Function signature
```py
def export_from_html(html : str, out_path : str) -> bool:
```
##### Parameters
- `html` - the HTML content that will be exported
- `out_path` - path of the newly created PDF
##### How to use
```py
from ocli.core.pdf_utils import export_from_html
export_from_html(html=html, out_path="Report.pdf")
```
Congratulations, you have successfuly generated your first PDF report!