A converter from RML to ODT.
This library implements a converter from Reportlabs RML format to Libreoffices/Open Document Formats ODT format utilizing the z3c.rml parser and odfpy library.
It’s developed by Shoobx (https://shoobx.com) but is open source, and we are happy to accept outside contributions. See DEVELOPMENT.rst for more information.
$ pip install shoobx.rml2odt
There is three ways of using shoobx.rml2odt.
From the command line
Installing shoobx.rml2odt will install a script that can be used from the command line:
rml2odt <infile> <outfile>
Converting files from Python
You can import shoobx.rml2odt as a library and convert files from Python:
>>> from shoobx.rml2odt import rml2odt >>> rml2odt.convertFile(infilepath, outfilepath)
which will convert the file at infilepath and create the ODT file at outfilepath.
Converting an RML string in Python
If your RML data isn’t in a file, but is held in a string, you can import shoobx.rml2odt as a library and convert text data from Python:
>>> from shoobx.rml2odt import rml2odt >>> odt_data = rml2odt.convertString(inputstring).read() >>> with open(outputfile, 'wb') as output: ... output.write(odt_data)
Upgrade to py3.7+
Changes for z3c.rml 4+ dependency
Add support for nested lists with different styling than parent
Add minor support for keepTogether tags, always displaying contents and keeping direct child blockTable elements on the same page
Add support for spanStyle tags.
Add support for underline attribute is paraStyle and spanStyle tags.
Complete overhaul of blockTable styling. This enables the use blockTableStyle and td styling tags. Most text, background and border styling is supported.
Fix: img must be in a Paragraph otherwise LibreOffice will not show the Image
Code cleanup and refactor
Lots of fixes, cleanup, tests added
Fix: blockSpan handling was completely broken
Fix: Removed whitespace from para left text, removed tail text of para tag
Fix: NextPage did not work, it added no page break
Fix: Do not add tabs to the ODT output, reportlab does not either. There’s a special tab tag that is used by our custom numbering.
Fix: Do not fail on missing value of the color tag
Fix: Support pre and xpre tags, make sure whitespace is not squashed
Fix: Copy the main or Main pageTemplate to Standard to make ODT at least somehow happy. Reportlab uses main as conventional default. This is still just a workaround. Supporting custom templates set in a story will take more efforts.
Copied all z3c.rml RML test inputs, blacklisted a lot, listed shortcomings.
Fix: Next paragraph text strip for custom bullets broken by 0.4.3.
Fix: bullet numbering ignored value as start
Fix: support all custom li bullets (l, L, o, O, r, R)
Fix: the br tag used a class variable to remember whether it added the style BreakJustify.
Fix span tag handling. It literally discarded most text.
Fix: Text following a comment tag was discarded.
Fix: 3+ whitespace was replaced with nothing. Caused text to miss spaces.
More indentation fixes.
Added support for O format lists (First, Second, Third)
Add support to have bullet lists in number lists and vice versa
Convert tables in lists to lists in lists
Support for blockSpan in table styles.
Handle tail text of comments
Supporting RML blockSpan styles for tables
Take the maximum, not the first when calculating the number of columns
Many many formatting fixes including an almost complete rewrite of list handling and list styles.
Cleaned up the public API.
Added basic docs.
Basic Support for:
Flowables: para, blockTable, hr, ul, ol
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.