node-convert

0.1.1 • Public • Published

node-office

NodeJS file converter using LibreOffice or OpenOffice software under the hood.

  • Convert PDF, Office and many other file types (supported file formats)
  • Generate file thumbnails
  • Callback and promise support
  • Output to file or buffer

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);

Output to buffer

const buffer = await office.convert('./test.doc');

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);

/node-convert/

    Package Sidebar

    Install

    npm i node-convert

    Weekly Downloads

    76

    Version

    0.1.1

    License

    MIT

    Unpacked Size

    2.18 MB

    Total Files

    26

    Last publish

    Collaborators

    • damian95