1.1.0 • Published 11 years ago

odt v1.1.0

Weekly downloads
6
License
-
Repository
github
Last release
11 years ago

node-odt

A node js tool to work with OpenDocument text files.

Install

  $ npm install odt

Usage

var fs = require('fs')
  , odt = require('odt')
  , template = odt.template
  , createWriteStream = fs.createWriteStream
var doc = 'mytemplate.ott';
var values = { 'subject': 'My subject value' };

// apply values

template(doc)
  .apply(values)
  .on('error', function(err){
    throw err;
  })
  .on('end', function(doc){

    // write archive to disk.

    doc.pipe(createWriteStream('mydocument.odt'))
    doc.finalize(function(err){
      if (err) throw err;
      console.log('document written!');
    });
  });

For a more advanced example see the command line utility in bin/node-odt.

API

Template

The main class to work with templates. It inherits from EventEmitter and fires the following events:

events

  • error - Fired if an error occurs.
  • end(document) - Fired when the document is complete.

.apply(values : Object)

Applies the values to the template. values is an object of the following form:

{
  "field-type": {
    "field-name": "field-value"
  }
}

e.g.

{
  "string": {
    "subject": "My subject",
    ...
  },
  ...
}
1.1.0

11 years ago

1.0.1

11 years ago

1.0.0

11 years ago

0.4.0

11 years ago

0.3.0

11 years ago

0.2.0

11 years ago

0.1.0

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago