DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:odt

OpenOffice.org/LibreOffice.org Export

Compatible with DokuWiki

  • 2014-09-29 "Hrun" yes
  • 2014-05-05 "Ponder Stibbons" yes
  • 2013-12-08 "Binky" yes
  • 2013-05-10 "Weatherwax" yes

plugin Exports a page to the Open Document format used by OpenOffice.org and other word processors

Last updated on
2015-06-28
Provides
Syntax, Render
Repository
Source
Conflicts with
inlineeditor, quickedit

Tagged with export, odt, pdf

This plugin allows you to export a page to the OpenDocument format used by OpenOffice.org, LibreOffice.org and other word processors. This is especially useful when you need to print or to give a single page to a customer (Hint: OpenOffice.org can also export to PDF).

This plugin was initialized by Andreas Gohr, and was then further developed and maintained by Aurelien Bompard.

The older version of ODT-plugin with default template support is from Florian Lamml.

Actually ODT is maintained by LarsDW223.

Usage

To make a single page exportable you can add the following macro to the page:

~~ODT~~

A better way is to integrate an export button into your template.

If you use the default template just switch the button on in the configuration menue.

Otherwise use the following to add another button in the upper or bottom button row of the template1)

<form class="button" method="get" action="<?php wl($ID)?>">
  <div class="no">
    <input type="submit" value="Export to ODT" class="button" />
    <input type="hidden" name="do" value="export_odt" />
    <input type="hidden" name="id" value="<?php echo $ID?>" />
  </div>
</form>

Or use this for a simple 16×16 icon somewhere in your template:

  <a href="<?php echo exportlink($ID, 'odt')?>"><img src="<?php echo DOKU_BASE?>lib/images/fileicons/odt.png" alt="ODT Export" /></a>

You can mix the 2 previous methods, and get a button with an image inside, with this code:

<form class="button" method="get" action="<?php wl($ID)?>">
  <div class="no">
    <button type="submit" class="button">
      <img src="<?php echo DOKU_BASE?>lib/images/fileicons/odt.png" alt="ODT Export" />
      Export to ODT
    </button>
    <input type="hidden" name="do" value="export_odt" />
    <input type="hidden" name="rev" value="<?php global $REV; echo $REV?>" />
    <input type="hidden" name="id" value="<?php echo $ID?>" />
  </div>
</form>

Development

Customizing

There are three ways of customizing how the output will look like :

  1. Modify an export of the wiki:syntax page:
    • Export the wiki:syntax page
    • Open the result with a ZIP-Archive tool and replace the provided styles.xml with the one from your document.
      Be careful, DokuWiki's caching system may get in the way when you do that. Remember to clean up your cache.
  2. Use the OpenOffice feature to load the styles from an existing file or template :
    • export your page in ODT, and open it in OpenOffice,
    • bring up the styles panel (F11),
    • click on the top-right icon,
    • choose “Load styles…” in the menu,
    • select all the checkboxes on the bottom (including “overwrite”),
    • click “From file…” on the bottom right and select your customized file, or select an existing template in the list.
  3. Use a pre-made template, see the following section for details on this feature.

Templates support

You may use templates to export your document. A template is a regular ODT file, as produced by OpenOffice (for example, not tested with other ODT-supporting applications).

In your wiki page, add the following code:

  {{odt>template:your template file name.odt}}

and upload your template to the wiki using the media manager. By default, you must put it in an :odt namespace (Meaning an “odt” directory right below the root in your wiki). The folder name can be configured using the admin page.

The exported page will be added after the content of your template. If you include the string DOKUWIKI-ODT-INSERT in the template, the wiki page will be inserted there (replacing the string).

:!: Warning : the DOKUWIKI-ODT-INSERT string must not be formatted in any way. To do that, select the line with this string, go to the “Format” menu, and click on the “Default Format” option (the first one).

There are two additional tags you may use in your template : DOKUWIKI-ODT-CUT-START and DOKUWIKI-ODT-CUT-STOP. All the text between these tags will be removed on export. There's a good reason for this feature : in an ODT file, the only styles that will be saved are the styles which are applied to some content in the document. If you want to create an empty ODT document for this plugin, and still want to define styles which will be applied to the wiki content, you have to write some dummy text, apply the styles to this text, and surround the text in the DOKUWIKI-ODT-CUT-START and DOKUWIKI-ODT-CUT-STOP tags. This way, the styles will be retained in the ODT file, but the dummy text will be removed on export.

Other plugins

If you use other syntax plugins, their output may not appear in the exported ODT document: those plugins must be modified to support the ODT output format. However, some plugins already support it.

Plugin Description
Fields User-defined fields support – Together with the fields plugin, you can store data in user-defined fields in your page, and recall this data from anywhere in your document (even in the headers and footers). See the fields plugin documentation page for more information.

In OpenOffice, user-defined fields are accessible using the Insert menu → Field → Other, “Variables” tab, and “User fields” section on the left.

This is very useful for document references, project names, etc.
Notes The nice-looking notes provided by the note plugin are exported to ODT.
Include The include plugin will let you generate a single ODT file from multiple wiki pages, just like for XHTML.
Math2 The math2 plugin will let you insert mathematical formulas in a wiki page. Support for the ODT format which should be imminent. In the meantime, you can apply this code.
LaTeX The LaTeX rendering plugin also will let you insert mathematical formulas in a wiki page, using a back-end LaTeX compiler.
mimetex Exports TeX expressions as images using the standalone mimeTeX executable
Chem The chem plugin formats a molecular formula by using <chem> tag. The latest version supports to export ODT format.
Color The color color plugin is really a demo of a simple a syntax plugin. ( Only in code at wikipage, not in download from GitHub)
DivAlign2 paragraph alignment. partial support (enhancements in progress)
nspages The nspages plugin creates TOC of namespaces. The latest version supports the ODT format.
sapnotelink The sapnotelink plugin creates SAP note links.
columns
definitionlist Working, with one open issue
emphasis
fields
geotag
include
note confirm
stars2
typography Works, with little limitations

See also ODT render support for howto and current initiatives.

Translations

The plugin is translated into English, German, Danish, French, Korean, Dutch and Japanese. Thanks a lot to the translators, new languages are very welcome!

Please use the DokuWiki Localization Tool.

Bugs

To report bugs or suggest features, please use GitHub Issues. The author does not monitor this page.

1) In /lib/tpl/default/main.php, there are two divs that contain some buttons: <div class=“bar” id=“bar__top”> and <div class=“bar” id=“bar__bottom”>. Just insert the HTML code inside one of the two divs (left or right)
plugin/odt.txt · Last modified: 2015-07-13 19:56 by LarsDW223