node-convert
v0.1.1
Published
NodeJS office converter using LibreOffice or OpenOffice.
Downloads
335
Maintainers
Readme
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);