Welcome to ezodf’s documentation!

ezodf is a Python package to create new or open existing OpenDocumentFormat files to extract, add, modify or delete document data. Supported python versions are CPython 2.7 and CPython 3.2+, because the lxml package is needed, PyPy support isn’t possible at this time (08.06.2012).

To open an existing document, just use the ezodf.opendoc() function:

doc = ezodf.opendoc('documentname.ext')

You don’t have to care about the document type at the open function, to check the type of the document, use the doctype or the mimetype attribute:

if doc.doctype == 'odt':
    pass
    # this is a text document
    # and so on for 'ods', 'odg' or 'odp'

To change the meta data of the document use the meta attribute, which is an instance of the meta.Meta class:

document_title = doc.meta['title']
# or set meta attributes
doc.meta['description'] = 'set a new description'

And save the modified document with the same filename as opened, a backup of the original file will be created (if not disabled):

doc.save()

or save it with a new name:

doc.saveas('newname.ext')
Flattr this

Indices and tables

Table Of Contents

Next topic

Introduction

This Page