ODT
Create LibreOffice Writer documents (.odt) from simple blocks, fill .odt templates with JSON values (fields, repeated table rows and list items, conditions, images), and read any .odt back as plain text, Markdown, table rows, or figures and properties. The blocks, template syntax and results are the same as for the Word functions, so a script can switch between the two formats. Typical uses: mail merge of letters and invoices for a team on LibreOffice, a monthly report sent as .odt, the text of a received document given to a language model or a search index.
odt createodt createodt fillodt fillodt placeholdersodt to_textodt to_textodt to_markdownodt tablesodt tablesodt info

odt create <out_path> <json_blocks>


Description

    Create a document from blocks, the same as docx create: {"type": "heading", "level": 1 to 6, "text" or "runs", "align"}, {"type": "paragraph", "text" or "runs", "align": left, center, right or justify, "indent": mm}, {"type": "bullet_list" or "numbered_list", "items": [text or {"text" or "runs", "level": 0 to 8, "numbered": true or false}]}, {"type": "table", "header": [...], "rows": [[...]], "widths": [mm]}: a cell is a value, a run or a list of runs, the header row is repeated on each page, {"type": "image", "path", "width", "height", "align"} in pixels at 96 dpi: with no size, the natural size reduced to the width of the page (so a 30000 x 10 image is accepted), with a size, at most 20000 pixels on each side, {"type": "page_break"}, {"type": "rule"}. A run: {"text", "bold", "italic", "underline", "color": "#RRGGBB", "size": points, "font", "link"}, http, https, mailto, ftp or tel links only. A line break in a text gives a line break. Returns {out_path, blocks}

Parameters

    out_path:   The .odt file to write (the folders are created, an existing file is replaced) - String - required
    json_blocks:   The blocks: a JSON array - String - required
admin
odt create "tmp/doc_odt/report.odt" "[{\"type\": \"heading\", \"level\": 1, \"text\": \"Report\"}, {\"type\": \"paragraph\", \"runs\": [{\"text\": \"Sales are \"}, {\"text\": \"up\", \"bold\": true}, {\"text\": \" and \"}, {\"text\": \"stable\", \"italic\": true}, {\"text\": \", see \"}, {\"text\": \"the site\", \"link\": \"https://www.mentdb.org\"}]}, {\"type\": \"heading\", \"level\": 2, \"text\": \"Actions\"}, {\"type\": \"bullet_list\", \"items\": [\"Call\", {\"text\": \"the bank\", \"level\": 1}, \"Pay\"]}, {\"type\": \"numbered_list\", \"items\": [\"First\", \"Second\"]}, {\"type\": \"table\", \"header\": [\"Shop\", \"Amount\"], \"rows\": [[\"A\", 100], [\"B\", 250.5]], \"widths\": [60, 40]}]"
mentdb
{"out_path": "tmp/doc_odt/report.odt", "blocks": 6}
An image and a page break
admin
image from_base64 "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAECAIAAAA8r+mnAAAAEUlEQVR42mNQSDiAFTFQTwIAvM0oAdPssEsAAAAASUVORK5CYII=" "tmp/doc_odt/logo.png"; odt create "tmp/doc_odt/image.odt" "[{\"type\": \"image\", \"path\": \"tmp/doc_odt/logo.png\", \"width\": 160, \"align\": \"center\"}, {\"type\": \"page_break\"}, {\"type\": \"paragraph\", \"text\": \"Page 2\"}]"
mentdb
{"out_path": "tmp/doc_odt/image.odt", "blocks": 3}

odt create <out_path> <json_blocks> <json_params>


Description

    Create with parameters: page_size (A4, A3, A5, Letter, Legal), orientation (portrait, landscape), margins (mm: a number, or an object with top, bottom, left, right; 25), font (Liberation Sans), size (points, 11), title, subject, author (MentDB), created (a date like 2026-11-04T08:00:00Z; the time of the call by default). An unknown parameter is an error

Parameters

    out_path:   The .odt file to write (the folders are created, an existing file is replaced) - String - required
    json_blocks:   The blocks: a JSON array - String - required
    json_params:   The parameters - String - required
admin
odt create "tmp/doc_odt/report.odt" "[{\"type\": \"heading\", \"level\": 1, \"text\": \"Report\"}, {\"type\": \"paragraph\", \"runs\": [{\"text\": \"Sales are \"}, {\"text\": \"up\", \"bold\": true}, {\"text\": \" and \"}, {\"text\": \"stable\", \"italic\": true}, {\"text\": \", see \"}, {\"text\": \"the site\", \"link\": \"https://www.mentdb.org\"}]}, {\"type\": \"heading\", \"level\": 2, \"text\": \"Actions\"}, {\"type\": \"bullet_list\", \"items\": [\"Call\", {\"text\": \"the bank\", \"level\": 1}, \"Pay\"]}, {\"type\": \"numbered_list\", \"items\": [\"First\", \"Second\"]}, {\"type\": \"table\", \"header\": [\"Shop\", \"Amount\"], \"rows\": [[\"A\", 100], [\"B\", 250.5]], \"widths\": [60, 40]}]" "{\"title\": \"Monthly report\", \"author\": \"MentDB\", \"created\": \"2026-11-04T08:00:00Z\"}"
mentdb
{"out_path": "tmp/doc_odt/report.odt", "blocks": 6}
Landscape Letter in DejaVu Sans with small margins
admin
odt create "tmp/doc_odt/letter.odt" "[{\"type\": \"paragraph\", \"text\": \"One short line\"}]" "{\"page_size\": \"Letter\", \"orientation\": \"landscape\", \"margins\": {\"top\": 15, \"bottom\": 15, \"left\": 20, \"right\": 20}, \"font\": \"DejaVu Sans\", \"size\": 12, \"title\": \"Note\", \"created\": \"2026-11-04T08:00:00Z\"}"
mentdb
{"out_path": "tmp/doc_odt/letter.odt", "blocks": 1}
Used in use cases (3 recipes)

    XML, HTML & Word integrator › Write one LibreOffice letter per customer from a single template
    Integrator & ETL developer › Publish the sales of the month as a LibreOffice document, then read its table back
    XML, HTML & Word integrator › Read a contract received as .odt: figures, Markdown for an assistant, a Word copy
Often used with

    file delete  ·  file exist  ·  file mkdir  ·  string char  ·  json doc  ·  json iobject  ·  odt fill  ·  odt tables

odt fill <template> <out_path> <json_data>


Description

    Fill a template and write the result (.odt, or .ott to keep a template). Returns {out_path, replaced (values and images inserted), unresolved (names without a value, and invalid placeholders such as {{a b}} which stay as they are)}. An unknown placeholder becomes empty and an unknown section false. An image is given by {"path": ..., "width": pixels, "height": pixels}, or its path alone: png, jpg or gif, the ratio is kept when only one size is given, the size of the file when none (not reduced to the page here: at most 20000 pixels on each side)

Parameters

    template:   The .odt (or .ott) template - String - required
    out_path:   The .odt file to write (the folders are created, an existing file is replaced) - String - required
    json_data:   The values: a JSON object - String - required
admin
odt create "tmp/doc_odt/tpl.odt" "[{\"type\": \"heading\", \"level\": 1, \"text\": \"Invoice {{number}}\"}, {\"type\": \"paragraph\", \"text\": \"Customer: {{customer.name}}, {{customer.city}}\"}, {\"type\": \"table\", \"header\": [\"Item\", \"Qty\", \"Price\"], \"rows\": [[\"{{#lines}}{{item}}\", \"{{qty}}\", \"{{price}}{{/lines}}\"], [\"Total\", \"\", \"{{total}}\"]]}, {\"type\": \"paragraph\", \"text\": \"{{?paid}}Paid, thank you.{{/paid}}{{^paid}}Payment due within 30 days.{{/paid}}\"}, {\"type\": \"bullet_list\", \"items\": [\"{{#notes}}{{.}}{{/notes}}\"]}]"; odt fill "tmp/doc_odt/tpl.odt" "tmp/doc_odt/invoice.odt" "{\"number\": \"F-2026-042\", \"customer\": {\"name\": \"Atelier Payet\", \"city\": \"Saint-Denis\"}, \"lines\": [{\"item\": \"Pen\", \"qty\": 2, \"price\": 3.5}, {\"item\": \"Ink\", \"qty\": 1, \"price\": 12}], \"total\": 19, \"paid\": false, \"notes\": [\"Delivered on Monday\", \"Keep this invoice\"]}"
mentdb
{"out_path": "tmp/doc_odt/invoice.odt", "replaced": 12, "unresolved": []}
The invoice read back
admin
odt to_text "tmp/doc_odt/invoice.odt"
mentdb
Invoice F-2026-042 Customer: Atelier Payet, Saint-Denis Item Qty Price Pen 2 3.5 Ink 1 12 Total 19 Payment due within 30 days. - Delivered on Monday - Keep this invoice
A loop over paragraphs and an image
admin
odt create "tmp/doc_odt/people_tpl.odt" "[{\"type\": \"paragraph\", \"text\": \"{{%logo}}\"}, {\"type\": \"paragraph\", \"text\": \"{{#people}}\"}, {\"type\": \"paragraph\", \"text\": \"{{name}}: {{#tags}}[{{.}}]{{/tags}}\"}, {\"type\": \"paragraph\", \"text\": \"{{/people}}\"}]"; odt fill "tmp/doc_odt/people_tpl.odt" "tmp/doc_odt/people.odt" "{\"logo\": {\"path\": \"tmp/doc_odt/logo.png\", \"width\": 80}, \"people\": [{\"name\": \"Ann\", \"tags\": [\"x\", \"y\"]}, {\"name\": \"Bob\", \"tags\": []}]}"
mentdb
{"out_path": "tmp/doc_odt/people.odt", "replaced": 5, "unresolved": []}
One placeholder without value
admin
odt fill "tmp/doc_odt/tpl.odt" "tmp/doc_odt/partial.odt" "{\"number\": \"F-1\"}"
mentdb
{"out_path": "tmp/doc_odt/partial.odt", "replaced": 1, "unresolved": ["customer.name", "customer.city", "lines", "total", "paid", "notes"]}

odt fill <template> <out_path> <json_data> <json_params>


Description

    Fill with parameters: strict (false; true: an unknown placeholder, section or invalid placeholder is an error and nothing is written), missing (the text of an unknown value, empty by default), max_rows (10000, the largest number of passes of a loop, up to 100000)

Parameters

    template:   The .odt (or .ott) template - String - required
    out_path:   The .odt file to write (the folders are created, an existing file is replaced) - String - required
    json_data:   The values: a JSON object - String - required
    json_params:   The parameters - String - required
admin
odt fill "tmp/doc_odt/tpl.odt" "tmp/doc_odt/partial.odt" "{\"number\": \"F-1\"}" "{\"missing\": \"n/a\"}"
mentdb
{"out_path": "tmp/doc_odt/partial.odt", "replaced": 1, "unresolved": ["customer.name", "customer.city", "lines", "total", "paid", "notes"]}
All the values must be known
admin
odt fill "tmp/doc_odt/tpl.odt" "tmp/doc_odt/strict.odt" "{\"number\": \"F-2026-042\", \"customer\": {\"name\": \"Atelier Payet\", \"city\": \"Saint-Denis\"}, \"lines\": [{\"item\": \"Pen\", \"qty\": 2, \"price\": 3.5}, {\"item\": \"Ink\", \"qty\": 1, \"price\": 12}], \"total\": 19, \"paid\": false, \"notes\": [\"Delivered on Monday\", \"Keep this invoice\"]}" "{\"strict\": true}"
mentdb
{"out_path": "tmp/doc_odt/strict.odt", "replaced": 12, "unresolved": []}
Used in use cases (2 recipes)

    XML, HTML & Word integrator › Write one LibreOffice letter per customer from a single template
    Integrator & ETL developer › Publish the sales of the month as a LibreOffice document, then read its table back
Often used with

    file delete  ·  file exist  ·  file mkdir  ·  json doc  ·  json iobject  ·  odt create  ·  string char  ·  odt placeholders

odt placeholders <template>


Description

    The placeholders of a template, even split by LibreOffice across spans, in the order of the document (text, then headers and footers): name, type (value, loop, if, unless, image, or invalid for {{a b}}), count. Closing markers are not listed

Parameters

    template:   The .odt (or .ott) template - String - required
admin
odt placeholders "tmp/doc_odt/tpl.odt"
mentdb
[{"name": "number", "type": "value", "count": 1}, {"name": "customer.name", "type": "value", "count": 1}, {"name": "customer.city", "type": "value", "count": 1}, {"name": "lines", "type": "loop", "count": 1}, {"name": "item", "type": "value", "count": 1}, {"name": "qty", "type": "value", "count": 1}, {"name": "price", "type": "value", "count": 1}, {"name": "total", "type": "value", "count": 1}, {"name": "paid", "type": "if", "count": 1}, {"name": "paid", "type": "unless", "count": 1}, {"name": "notes", "type": "loop", "count": 1}, {"name": ".", "type": "value", "count": 1}]
Used in use cases (1 recipe)

    XML, HTML & Word integrator › Write one LibreOffice letter per customer from a single template
Often used with

    file delete  ·  file exist  ·  file mkdir  ·  json doc  ·  json iobject  ·  odt create  ·  odt fill  ·  odt to_text

odt to_text <path>


Description

    The plain text of a document: one line per paragraph, list items with - or their number and an indentation, one line per table row with tabs between the cells, the text of the frames after their paragraph. Empty paragraphs are skipped; images, footnotes, comments and deleted text are ignored

Parameters

    path:   The .odt file (also .ott, and the flat XML .fodt) - String - required
admin
odt to_text "tmp/doc_odt/report.odt"
mentdb
Report Sales are up and stable, see the site Actions - Call - the bank - Pay 1. First 2. Second Shop Amount A 100 B 250.5

odt to_text <path> <json_params>


Description

    Plain text with parameters: cell_separator (a tab), list_markers (true), headers (false; true adds the text of the headers before and of the footers after)

Parameters

    path:   The .odt file (also .ott, and the flat XML .fodt) - String - required
    json_params:   The parameters - String - required
admin
odt to_text "tmp/doc_odt/report.odt" "{\"cell_separator\": \";\", \"list_markers\": false}"
mentdb
Report Sales are up and stable, see the site Actions Call the bank Pay First Second Shop;Amount A;100 B;250.5
Used in use cases (1 recipe)

    XML, HTML & Word integrator › Write one LibreOffice letter per customer from a single template
Often used with

    file delete  ·  file exist  ·  file mkdir  ·  json doc  ·  json iobject  ·  odt create  ·  odt fill  ·  odt placeholders

odt to_markdown <path>


Description

    The document as Markdown, as docx to_markdown: headings, bold, italic, bullet and numbered lists with their levels, tables (the first row as header), links (only http, https, mailto, ftp, tel and relative addresses; other links keep their text). Images, footnotes and deleted text are ignored, and a table inside a cell gives only its text

Parameters

    path:   The .odt file (also .ott, and the flat XML .fodt) - String - required
admin
odt to_markdown "tmp/doc_odt/report.odt"
mentdb
# Report Sales are **up** and *stable*, see [the site](https://www.mentdb.org) ## Actions - Call - the bank - Pay 1. First 2. Second | Shop | Amount | | --- | --- | | A | 100 | | B | 250.5 |
Used in use cases (2 recipes)

    XML, HTML & Word integrator › Read a contract received as .odt: figures, Markdown for an assistant, a Word copy
    Integrator & ETL developer › Publish the sales of the month as a LibreOffice document, then read its table back
Often used with

    file delete  ·  file exist  ·  file mkdir  ·  odt create  ·  odt tables  ·  string char  ·  docx tables  ·  json doc

odt tables <path>


Description

    The tables of the text as a JSON array of tables, each one an array of rows, each one an array of cell texts (a merged cell gives empty cells so that the columns stay aligned; a table inside a cell only gives its text)

Parameters

    path:   The .odt file (also .ott, and the flat XML .fodt) - String - required
admin
odt tables "tmp/doc_odt/invoice.odt"
mentdb
[[["Item", "Qty", "Price"], ["Pen", "2", "3.5"], ["Ink", "1", "12"], ["Total", "", "19"]]]

odt tables <path> <json_params>


Description

    Tables with parameters: header (false; true: the first row gives the names and each table is an array of objects, which fits the functions on rows). Empty names become col_1, col_2..., repeated names get _2

Parameters

    path:   The .odt file (also .ott, and the flat XML .fodt) - String - required
    json_params:   The parameters - String - required
admin
odt tables "tmp/doc_odt/invoice.odt" "{\"header\": true}"
mentdb
[[{"Item": "Pen", "Qty": "2", "Price": "3.5"}, {"Item": "Ink", "Qty": "1", "Price": "12"}, {"Item": "Total", "Qty": "", "Price": "19"}]]
Used in use cases (2 recipes)

    XML, HTML & Word integrator › Read a contract received as .odt: figures, Markdown for an assistant, a Word copy
    Integrator & ETL developer › Publish the sales of the month as a LibreOffice document, then read its table back
Often used with

    file delete  ·  file exist  ·  file mkdir  ·  odt create  ·  odt to_markdown  ·  string char  ·  docx tables  ·  json doc

odt info <path>


Description

    The figures of a document: paragraphs (with those of the tables, lists and frames), tables, images, words, pages (from the statistics saved by LibreOffice, null when the file has none, as for the files written by odt create and odt fill), and its properties title, subject, author (initial creator), created and modified (ISO dates as written in the file, without fractions of a second; null when absent). Unlike docx info, there is no sections

Parameters

    path:   The .odt file (also .ott, and the flat XML .fodt) - String - required
admin
odt info "tmp/doc_odt/report.odt"
mentdb
{"paragraphs": 14, "tables": 1, "images": 0, "words": 22, "pages": null, "title": "Monthly report", "subject": null, "author": "MentDB", "created": "2026-11-04T08:00:00Z", "modified": "2026-11-04T08:00:00Z"}
Used in use cases (1 recipe)

    XML, HTML & Word integrator › Read a contract received as .odt: figures, Markdown for an assistant, a Word copy
Often used with

    docx tables  ·  file delete  ·  file exist  ·  file mkdir  ·  markdown to_docx  ·  odt create  ·  odt tables  ·  odt to_markdown