Fidus Writer now exports to DOCX and ODT!

blowing-15795_1920

Inspired by Mahdi Jaberzadeh Ansari’s work within OSCOSS on a converter program for Fidus Writer files to docx, we wanted to see if it was possible to bake an export system for Fidus Writer files to standard word processors right into Fidus Writer itself. It turned out that we could do it! The upcoming 3.1 branch contains both a ODT (LibreOffice/OpenOffice) export filter, and a DOCX (Microsoft Word 2016) export filter.

What is more, the export filters are built around a templating system, so that the administrator of a Fidus Writer site can create new templates using her/his word processor. The Fidus Writer user can choose to export Fidus documents using any of the templates installed on the given Fidus Writer installation.

The filters cover all features of Fidus Writer — figures, headlines, citations, formulas, etc. . The filters are first launched behind a new “experimental” setting in the upcoming Fidus Writer 3.1 beta version.

The “experimental” setting is new and is a result of our reflections on the kind of support we have delivered to users over the past few years. Writing is a process that takes a long time, and users need to be able to choose not to be subjected to features that have not been tested thoroughly. We expect the filters to improve over time as contributors adjust the filters to their needs.

Difficulties

The filters are mainly based on the specifications for the formats, but in some cases they needed to be adjusted to create working output in the word processors that were tested. Future tests with other word processors may reveal more issues, and new templates may introduce issues that we have not encountered so far.

Particularly difficult was the conversion of formulas. Fidus Writer stores the formulas in LaTeX format. We used TexZilla to convert them to MathML, the format used in ODT. For DOCX we first convert to MathML and then from there to the DOCX internal format OMML using an XSLT stylesheet included with Abiword. While the conversions went fine in our tests, each conversion carries the risk of not working correctly under all circumstances.

Another difficulty was adjusting the size of images to only fill as much space as there is for them. There is no simple way to make images fill 100% of the width of any page or column in DOCX, so we had to calculate the width by looking at the entire document. This works for text without columns or for simple columns that have even widths, but for columns with differing width, there doesn’t seem to be any way of knowing how much space there is a available for an image. In ODT files there is in theory a way to make images fill the full width, but LibreOffice doesn’t support that feature as it’s outlined in the spec. In the end we opted for a syntax that both follows the wording of the spec and seems to render correct results in LibreOffice.

What now?

Despite the various difficulties, the creation of these initial filters went surprisingly well. If you or your institution was just waiting for these filters, now is the time to install Fidus Writer, try them out and give some feedback or contribute some code to improve them! Donations are also always welcome!

Leave a Reply

Your email address will not be published. Required fields are marked *