Python library for OpenDocument Format
Project description
odfdo
Python library for OpenDocument format (ODF)
odfdo
is a Python3 library implementing the ISO/IEC 26300 OpenDocument Format
standard.
Project: https://github.com/jdum/odfdo
Author: jerome.dumonteil@gmail.com
License: Apache License, Version 2.0
odfdo
is a derivative work of the former lpod-python
project.
Installation
Installation from Pypi (recommended):
pip install odfdo
Installation from sources (requiring setuptools):
pip install .
After installation from sources, you can check everything is working (some requirements: pytest
, Pillow, ...):
pytest
The tests should run for a few seconds or minutes and issue no error.
The full test suite uses tox
to check different Python
and lxml
versions.
A special effort is made to limit the dependencies of this library: the only dependency (outside development) is lxml
. The lxml
versions depend mainly on the version of Python used, see the pyproject.toml
file for details.
Usage
from odfdo import Document, Paragraph
doc = Document('text')
doc.body.append(Paragraph("Hello world!"))
doc.save("hello.odt")
tl;dr
'Intended Audience :: Developers'
Documentation
There is no detailed documentation or tutorial, but:
- the
recipes
folder contains more than 60 working sample scripts, - the
doc
folder contains an auto generated HTML documentation, including recipes.
When installing odfdo, a few scripts are installed:
odfdo-diff
: show a diff between two .odt document.odfdo-folder
: convert standard ODF file to folder and files, and reverse.odfdo-show
: dump text from an ODF file to the standard output, and optionally styles and meta informations.odfdo-styles
: command line interface tool to manipulate styles of ODF files.odfdo-replace
: find a pattern (regex) in an ODF file and replace by some string.odfdo-userfield
: show or set the user-field content in an ODF file.odfdo-highlight
: highlight the text matching a pattern (regex) in an ODF file.odfdo-headers
: print the headers of an ODF file.odfdo-table-shrink
: shrink tables to optimize width and height.odfdo-markdown
: export text document in Markdown format to stdout.
About styles: the best way to apply style is by merging styles from a template
document into your generated document (See odfdo-styles
script).
Styles are a complex matter in ODF, so trying to generate styles programmatically
is not recommended.
Limitations
odfdo
is intended to facilitate the generation of ODF documents,
nevertheless a basic knowledge of the ODF format is necessary.
ODF document rendering can vary greatly from software to software. Especially the "styles" of the document allow an adaptation of the rendering for a particular software.
The best (only ?) way to apply style is by merging styles from a template
document into your generated document. However a few recipes show how to make
programmatically some basic styles: create_basic_text_styles
, add_text_span_styles
).
Related project
I you work on .ods
files (spreadsheet), you may be interested by these scripts using
this library to parse/generate .ods
files:
https://github.com/jdum/odsgenerator
and https://github.com/jdum/odsparsator
Changes from former lpod library
lpod-python
was written in 2009-2010 as a Python 2.x library,
see: https://github.com/lpod/lpod-python
odfdo
is an adaptation of this former project. odfdo
main changes from lpod
:
odfdo
requires Python version 3.9 to 3.13. For previous Python versions see older releases.- API change: more pythonic.
- include recipes.
- use Apache 2.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file odfdo-3.12.1.tar.gz
.
File metadata
- Download URL: odfdo-3.12.1.tar.gz
- Upload date:
- Size: 194.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff065d7b6a83a359ff0fd0e4ba25b8f1d903784bf39ab4aacb37d0061b508946 |
|
MD5 | 776c464ec3ffc534566a5a242b15b1fa |
|
BLAKE2b-256 | 2f172b784c3e33d1a15e47be906656a62d32a13dcf85d6a6bcb572354058f59c |
File details
Details for the file odfdo-3.12.1-py3-none-any.whl
.
File metadata
- Download URL: odfdo-3.12.1-py3-none-any.whl
- Upload date:
- Size: 247.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.20
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04a8f8593639a122e84bdc56ec78b47fae0f0969f2ac3b58d3518c8c93b699a7 |
|
MD5 | 58646db758e8a37b953fbc52f917b718 |
|
BLAKE2b-256 | 66c2fa75ece68b0903cadb69916e6018e82ff5483d95abda320d150b4d1c416f |