• skip to content

spacer DokuWiki

It's better when it's simple

User Tools

  • Log In

Site Tools

  • Recent Changes
  • Media Manager
  • Sitemap
Trace: odt

Sidebar

Learn about DokuWiki

  • Features & reviews
  • Installation guide
  • User manual & syntax
  • Release notes
  • FAQ

Advanced Use

  • Extensions
  • Development manual

Corporate Use

  • Get support
  • Donations

Our Community

  • Get involved
  • User forum
  • Newsletter
  • Development mailinglist

Follow us on Facebook, Twitter and other social networks.

plugin:odt

Table of Contents

  • OpenOffice.org/LibreOffice.org Export
    • Requirements
    • Usage
    • Settings
    • Configuration
    • Additional syntax tags
      • pagebreak
      • page
      • toc
      • disablelinks/enablelinks
    • Development
      • Preview
    • Customizing
      • Templates support
    • ODT support for plugins
    • Translations
    • Bugs

OpenOffice.org/LibreOffice.org Export

Compatible with DokuWiki

  • 2015-08-10 "Detritus" yes
  • 2014-09-29 "Hrun" yes
  • 2014-05-05 "Ponder Stibbons" yes
  • 2013-12-08 "Binky" yes
  • Download
  • Report bugs

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

Last updated on
2015-10-03
Provides
Syntax, Render
Repository
Source
Conflicts with
inlineeditor, quickedit

Tagged with export, odt, pdf

By Andreas Gohr, Aurélien Bompard, Florian Lamml, Lars (LarsDW223)

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.

Requirements

PHP 5.5 (for PHP 5.3.3+ and PHP 5.4.X, see this workaround)

There are no requirements in general but some features have requirements:

  • Bookcreator: for bookcreator support you need to install the bookcreator plugin too.
  • Pagebreak: to be able to insert pagebreaks manually you need to install the pagebreak plugin too.

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>

Settings

Most settings or configuration options in the ODT plugin can be set in the ODT plugin configuration, by passing the setting as a URL request parameter or by using the syntax tag.

The precedence is like this (first entry has highest precedence, last entry has lowest):

  1. syntax tag
  2. URL request parameter
  3. ODT plugin configuration setting
  4. DokuWiki configuration setting
    (only relevant for 'toc_maxlevel', see Configuration section below)

This is an example for passing the setting orientation as a URL request parameter:

https://www.dokuwiki.org/plugin:odt?orientation=landscape&do=export_odt

The same works for syntax tags. The syntax tags for settings always have the same format:

{{odt>setting:value}}

Here again the example for the setting orientation:

{{odt>orientation:landscape}}

Configuration

The current release has the following configuration options:

Config option name Function
tpl_dir Sub-directory for the templates in the media manager. Upload your ODT template files to this directory.
odt_template ODT file which shall be used as a template. Per default this field is empty. In that case default styles are used.
showexportbutton Display the ODT Export Button?
media_sel Which @media selector shall be used to query CSS properties? For example 'print' or 'screen'. Currently this only affects the ODT export of plugins, e.g. the Wrap plugin.
css_template The dokuwiki template to use for CSS import. This only affects the CSS content given to plugins. It does not affect the look of the DokuWiki basic syntax.
usestyles You can give a comma separated list of plugins of which the style.css or screen.css should be used for ODT generation. By default only print.css and odt.css are used.
twips_per_pixel_x Twips per pixel on the X axis.
twips_per_pixel_y Twips per pixel on the Y axis.
format The page format of the exported document. The current formats are currently supported:
A6, A5, A4, A3, B6 (ISO), B5 (ISO), B4 (ISO), Letter, Legal, Long Bond, Tabloid, B6 (JIS), B5 (JIS), B4 (JIS), 16 Kai, 32 Kai, Big 32 Kai, DL Envelope, C6 Envelope, C6/5 Envelope, C5 Envelope, C4 Envelope, #6 3/4 Envelope, #7 3/4 (Monarch) Envelope, #9 Envelope, #10 Envelope, #11 Envelope, #12 Envelope, Japanese Postcard.
orientation Orientation of the exported document. This allows the option 'portrait' or 'landscape'.
margin Top, Right, Bottom, Left Margins for the exported document in centimeters.
disable_links If set to 'Yes', links will not be encoded as links but just as plain text.
toc_maxlevel Maximum depth for the table of contents. If empty, the value of the global DokuWiki option 'maxtoclevel' is used.
toc_leader_sign The leader sign to be inserted in the table of contents.
toc_indents The indentation for the table of contents per level. The values are absolute values in centimeters, not relative to the previous level. E.g. the setting '0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5' leads to a indentation of 0.5 centimeters more per level. While '0, 1, 1, 1, 1, 1, 1, 1, 1, 1' keeps level 1 not indented and all other levels have the same 1 centimeter indentation.
toc_pagebreak Insert a pagebreak after the table of contents?
toc_style Style to be used for the table of contents in CSS format, e.g.: 'color:red;'. Each level uses the same style per default. You can assign specific styles using the syntax tag.

Additional syntax tags

There are some syntax tags for additional features which can not be set in the configuration alone because e.g. the position matters or to provide more flexibility. These tags are described in this section.

pagebreak

A manual pagebreak can be inserted by adding the syntax tag <pagebreak> in the wiki page. This feature requires the plugin pagebreak.

page

The syntax tag page can be used to set the page format, orientation and margins with one single command. The format is the following:

{{odt>page:format,orientation,margin_top,margin_right,margin_bottom,margin_left}}

The following example sets the page format A3, orientation landscape and all margins to 1 centimeter.

{{odt>page:A3,landscape,1,1,1,1}}

You can also omit parameters that you do not want to change, e.g.:

{{odt>page:A3,landscape}}

That changes the page format and orientation but not the margins.

If you want to alter a single page property only, then you can use the settings tags for format, orientation or the margins alone. See some examples below:

{{odt>format:A3}}
{{odt>format:A4}}

{{odt>orientation:portrait}}
{{odt>orientation:landscape}}

{{odt>margin_top:1}}
{{odt>margin_right:2}}
{{odt>margin_left:3}}
{{odt>margin_bottom:4}}

A change of the page format will finish the current page, cause a pagebreak and the next page will then use the newly set page format.

toc

The toc syntax tag can be used to insert a table of contents at the position of the tag. Without inserting the toc syntax tag, no table of contents will be created at all. The minimum syntax is:

{{odt>toc}}

This will create a table of contents with all relevant settings taken from the ODT plugin configuration. The title will be 'Table of Contents' (depending on the language set).

The following options for the toc syntax tag do exist:

  • maxlevel: this overwrites toc_maxlevel
  • title: this overwrites the language specific default title 'Table Of Contents'
  • leader_sign: this overwrites toc_leader_sign
  • indents: this overwrites toc_indents
  • pagebreak: this overwrites toc_pagebreak
  • styleL1 … styleLN: N = maxlevel, overwrites toc_style

These have all the same meaning as the corresponding configuration settings. Only exception is styleL1 … styleLN. The configuration setting toc_style sets the style for the whole table of contents. styleL1 only sets the style for toc level 1, styleL2 only sets the style for toc level 2…

All these options are optional. If you omit one, then the corresponding setting of the configuration (or URL request parameter) will be used. Every option needs to be finished with a ; .

Here are some examples (all one line):

{{odt>toc:title=Content;leader_sign=.;indents=0,0.5,1;pagebreak=true;
styleL1="font-weight:bold;";styleL2="font-style:italic;";
styleL3="font-style:normal;";}}
{{odt>toc:title=Content;leader_sign=_;indents=0,2,2;pagebreak=false;
styleL1="font-weight:bold;";styleL2="font-style:normal;";
styleL3="font-style:normal;";}}

These tags enable or disable link creation just like the configuration setting. Here is the syntax:

{{odt>disablelinks}}
{{odt>enablelinks}}

Development

Changes:

Latest Release:

  • Updated version for releasing it.
  • Fixed broken bookcreator export by correcting the loading of the action component export.php. Fixes #84.
  • Corrected insertion of local links for anchors. An anchor was not converted to an ODT link
  • Deleted faulty extra space in names of table alignment styles (left, right, center). Fixes #83.
  • Fixed usage of empty(). If the parameter passed to empty() is not just a variable,
  • Corrected comparison with $ACT. $ACT can sometimes be an array.
  • Merge pull request #74 from phillip-hopper/MoveTestData
  • Move the test data to the Dokuwiki TMP_DIR directory

Development master branch:

  • Merge pull request #122 from dokuwiki-translate/lang_update_151
  • translation update
  • Merge pull request #121 from a-gundy/rtl-pagetool
  • Changed style to keep pagetool icon on left side for rtl languages
  • Added simple integration test for basic text formating.
  • Added new function XMLUtil::getAttributes() for easier attributes decoding.
  • Corrected paragraph encoding. The attribute "style:family" was missing for dynamically generated (not imported) paragraph styles. Fixes #120.
  • Added test code to test the correct start of the ODT document content.

Release 20101030 with Default Template Support: dokuwiki-odt-20140210.
More older releases are available

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.