/node-office

NodeJS office converter using LibreOffice or OpenOffice.

Primary LanguageTypeScriptMIT LicenseMIT

node-office

NodeJS office converter using LibreOffice or OpenOffice.

  • Convert PDF, Office and many other files types
  • Easily generate file thumbnails
  • Callback and promise support

Installation

npm install --save node-office

// or

yarn add node-office

Usage

Convert files

Convert a single DOC to PDF

await office.convert('./test.doc', './test.pdf');

Convert a single file with callback function

function callback() {
  console.log('Done!');
}

office.convert('./test.doc', './test.pdf', callback);

Generate thumbnails

Thumbnails can be generated by converting a file to an image format like JPEG or PNG.

Generate a thumbnail for a single file

await office.convert('./test.doc', './test.jpg');
await office.convert('./marketing.pdf', './marketing.jpg');

Different ways to import node-office

ES6 Import syntax

import office from 'node-office';

await office.convert('./test.doc', './test.pdf');
import { convert, listen } from 'node-office';

await convert('./test.doc', './test.pdf');

CommonJS require syntax

const office = require('node-office');

function cb() {
  console.log('Conversion complete');
}

office.convert('./test.doc', './test.pdf', cb);
const convert = require('node-office').convert;

function cb() {
  console.log('Conversion complete');
}

convert('./test.doc', './test.pdf', cb);