JSPM

better-unoconv

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1923
  • Score
    100M100P100Q123606F
  • License MIT

A better wrapper for converting documents with unoconv.

Package Exports

  • better-unoconv

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (better-unoconv) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

better-unoconv

A better node.js wrapper for converting documents with unoconv that runs on node v7.x.

Requirements

Unoconv is required, which requires LibreOffice (or OpenOffice.)

Install

Install with:

npm install unoconv

Converting documents

var unoconv = require('better-unoconv');

unoconv.convert('document.docx', 'pdf', function (err, result) {
    // result is returned as a Buffer
    fs.writeFile('converted.pdf', result);
});

Starting a listener

You can also start a unoconv listener to avoid launching Libre/OpenOffice on every conversion:

unoconv.listen();

API

unoconv.convert(file, outputFormat, [options], callback)

Converts file to the specified outputFormat. options is an object with the following properties:

  • bin Path to the unoconv binary
  • port Unoconv listener port to connect to

callback gets the arguments err and result. result is returned as a Buffer object.

unoconv.listen([options])

Starts a new unoconv listener. options accepts the same parameters as convert().

Returns a ChildProcess object. You can handle errors by listening to the stderr property:

var listener = unoconv.listen({ port: 2002 });

listener.stderr.on('data', function (data) {
    console.log('stderr: ' + data.toString('utf8'));
});

unoconv.detectSupportedFormats([options], callback)

This function parses the output of unoconv --show to attempt to detect supported output formats.

options is an object with the following properties:

  • bin Path to the unoconv binary

callback gets the arguments err and result. result is an object containing a collection of supported document types and output formats.