Exports a page to the Open Document format used by OpenOffice.org and other word processors
Compatible with DokuWiki
2007-06-26 and later
Similar to bookcreator, mellelexport, odp, pdfbook
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.
Latest release: dokuwiki-odt-20101030.zip (signature)
Changes:
Older releases are available on this webpage.
The development can be tracked on Gitorious.
This plugin works with DokuWiki 2007-06-26 and later.
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>
There are three ways of customizing how the output will look like :
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.
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.
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.
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.
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.
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.
The LaTeX rendering plugin also will let you insert mathematical formulas in a wiki page, using a back-end LaTeX compiler. Support for ODT export is now included.
The chem plugin formats a molecular formula by using <chem> tag. The latest version supports to export ODT format.
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.
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
The nspages plugin creates TOC of namespaces. The latest version supports the ODT format.
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!
To report bugs or suggest features, please use the plugin's tracker. The author does not monitor this page.
diff -ur odt.old/renderer.php odt/renderer.php --- odt.old/renderer.php 2010-10-30 11:25:54.000000000 +0200 +++ odt/renderer.php 2011-02-15 13:52:26.000000000 +0100 @@ -307,6 +307,9 @@ function document_end_scratch(){ $autostyles = $this->_odtAutoStyles(); $userfields = $this->_odtUserFields(); + foreach ($this->extrastyles as $stylename=>$stylexml) { + $extrastyles .= $stylexml; + } // add defaults $this->ZIP->add_File('application/vnd.oasis.opendocument.text', 'mimetype', 0); @@ -364,6 +367,7 @@ $value = io_readFile(DOKU_PLUGIN.'odt/styles.xml'); $value = str_replace('<office:automatic-styles/>', $autostyles, $value); + $value = str_replace('<office:extra-styles/>', $extrastyles, $value); $this->ZIP->add_File($value,'styles.xml'); // build final manifest @@ -910,7 +914,16 @@ function _highlight($type, $text, $language=null) { global $conf; - $style_name = "Source_20_Code"; + if($language!=''){ + $style_name = "Code $language"; + $this->extrastyles["Code $language"] = ' + <style:style style:name="'."Code $language".'" style:display-name="Code '.$language.'" style:family="paragraph" style:parent-style-name="Preformatted_20_Text"> + <style:paragraph-properties fo:padding="0.05cm" style:shadow="none" fo:border="0.002cm solid #8cacbb" fo:background-color="#f7f9fa"/> + </style:style> + '; + } else{ + $style_name = "Source_20_Code"; + } if ($type == "file") $style_name = "Source_20_File"; if (is_null($language)) { diff -ur odt.old/styles.xml odt/styles.xml --- odt.old/styles.xml 2010-10-30 11:25:54.000000000 +0200 +++ odt/styles.xml 2011-02-15 13:45:09.000000000 +0100 @@ -113,6 +113,7 @@ <style:style style:name="Graphics" style:family="graphic"> <style:graphic-properties text:anchor-type="paragraph" svg:x="0cm" svg:y="0cm" style:wrap="dynamic" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="top" style:vertical-rel="paragraph" style:horizontal-pos="center" style:horizontal-rel="paragraph"/> </style:style> + <office:extra-styles/> <text:outline-style> <text:outline-level-style text:level="1" style:num-format=""> <style:list-level-properties text:min-label-distance="0.381cm"/>
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
Modifying Table Properties
We are trying to get tables not to break on page boardes - the progress is in here: http://user.services.openoffice.org/en/forum/viewtopic.php?f=44&t=34773&p=159918#p159918
It's because Windows doesn't support unicode file name so temp directories cannot be created. Change the temp file name to md5 can solve the problem.
=== (+2,-2) renderer.php === @@ -382,7 +382,7 @@ } else { $temp_dir = $conf['savedir'].'/cache/tmp'; // version <= 20070626 } - $this->temp_dir = $temp_dir."/odt/".str_replace(':','-',$ID); + $this->temp_dir = $temp_dir."/odt/".md5($ID); if (is_dir($this->temp_dir)) { $this->io_rm_rf($this->temp_dir); } io_mkdir_p($this->temp_dir);
— danny0838danny0838
2011/01/26 14:57
If you use \\\n as single linebreak, there would be an extra space after the linebreak in the output odt. This can be fixed by adding an instruction in the document_end funciton in the renderer.php:
$this->doc = preg_replace('#<text:p[^>]*>\s*</text:p>#', '', $this->doc); + $this->doc = preg_replace('#<text:line-break/>\n+#', '<text:line-break/>', $this->doc);
— danny0838danny0838
2011/01/28 04:51
It would be great if this plugin could also export text descriptions that link to files:
[[ks:somepage|This text describing an internal link is exported to ODT]]
[[http://www.google.com|This text describing an external link is also exported to ODT]]
{{:somefile.pdf|This text describing a link to a document is NOT exported to ODT}}
— Eagle 2011-08-29 15:42
/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)