Skip to content

damian66/node-convert

Repository files navigation

node-convert

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-convert

// or

yarn add node-convert

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 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 convert('./test.doc', './test.jpg');
await convert('./marketing.pdf', './marketing.jpg');

Different ways to import node-convert

ES6 Import syntax

import convert from 'node-convert';

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

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

CommonJS require syntax

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

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

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

About

NodeJS office converter using LibreOffice or OpenOffice.

Resources

License

Stars

Watchers

Forks

Packages

No packages published