OpenOffice.org Export

odt plugin by Andreas Gohr, Aurélien Bompard
Exports a page to the Open Document format used by OpenOffice.org and other word processors

Last updated on 2010-08-12. Provides Syntax, Render.
Compatible with DokuWiki 2007-06-26 and later.

Similar to bookcreator, mellelexport, pdfbook.

Tagged with export, odt, pdf.

This plugin allows you to export a page to the OpenDocument format used by OpenOffice.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 is now developed and maintained by Aurelien Bompard. If you have any requests (bugs, features, etc.), please use the plugin's tracker, the author does not monitor this page.

Download

Flattr this

Latest release: dokuwiki-odt-20100812.zip (signature)

Changes:

  • Syntax highlighting support ! This has been moderately tested on the code I had at hand, so please report any bug you can find.

Older releases are available on this webpage.

The development can be tracked on Gitorious.

This plugin works with DokuWiki 2007-06-26 and later.

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.

Use the following to add another button in the upper or bottom button row of the default 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>

Customizing

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

  • Modify the export of the wiki:syntax page. Then 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.
  • 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.
  • 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.

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. You need at least version 2008-02-17 of the note plugin for ODT support.

Include

The include plugin will let you generate a single ODT file from multiple wiki pages, just like for XHTML. Support for the ODT format is included in the latest release.

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.

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. A version has been produced including support for the ODT format.

DivAlign2

Hi. Just wanted you to know that I've made one of my plugins, divalign2 (paragraph alignment) compatible with ODT plugin output. I should also let you know by mail… — Luis Machuca B. 2009/08/22 06:26

Translations

The plugin is translated into English, German, French, Italian, Spanish, Japanese, Russian and Chinese. Thanks a lot to the translators, new languages are very welcome!

Bugs

To report bugs or suggest features, please use the plugin's tracker. The author does not monitor this page.

Discussion

General Use

Will someone write a short example how to integrate export button into template? I tried to do it myself, but CSS, PHP, HTML are unfamiliar for me. Template consist of 9 files of different types. Which file should be modified? Thanks. — Alexander 2008-02-29 17:57

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 provided in this page once and inside one of the two divs (left or right). If it doesn't please you, try another place.
Now it is wise not to edit this default template file but proceed as stated on this page.
Grahack 2008-03-02 10:02

It is possible to import ODT into DokuWiki?

Yes, have a look on http://www.linux.com/articles/41545 OOo User 2008-02-19 09:52
Though, it looks like the latest version of Writer's Tools for OOo has removed DokuWiki conversion.

How can I get the page title to be included in the template, not just as the name of the file ? —SME 2008/06/03


Thanks for this plugin! Downloaded, added the button in ACH template and works :-) – at least now, and I'm not using the template feature yet ;-)Werner Flamme 2008/09/04 21:29 CEST


Thanks for the GREAT plugin. works out of the box in no time! Is there any means of specifying the template in the link rather than the wiki code? I'd prefer a single modification to my template, like <?php echo exportlink($ID, 'odt&template=your_template_file name.odt')?> rather than having to put the required line in all pages… and having users messing with it. —Berteh 2008/10/22

for now I hacked the plugin to add a “template” option in config: hope this helps, feel free to correct this code if you spot errors. —Berteh 2008/10/22

1. add to odt/conf/default.php

$conf['tpl_template'] = 'my_custom_template.odt'; //comment this line to not use any template

2. add to odt/conf/metadata.php

$meta['tpl_template']   = array('string');

3. edit function document_end() in odt/renderer.php: (line 250)

function document_end(){
+      if (!$this->template) { // if no template chosen in current page, get default template from config
+           $this->template=$this->getConf("tpl_template");
+      }
+
       if ($this->template) { // template chosen
That's a good idea, I should probably include that at some point. — Aurélien Bompard 2010/04/04 11:21

ODT export error
I bumped into the problem that ODT export stopped working for me, even the pdf export stopped working. After a long time I found the error. In the global apache2 php.ini file mbstring.func_overload was set to 7 by mantis bug tracker (mbstring.func_overload = 7).
Dokuwiki ODT export does not like this setting. It has to be mbstring.func_overload = 0 or if you wish to set it only for one site use .htaccess (php_value mbstring.func_overload 0). Sören

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: 2010/08/13 11:20 by 92.79.17.136
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate