libreoffice-convert

A simple and fast node.js module for converting office documents to different formats

libreoffice-convert downloads libreoffice-convert version libreoffice-convert license

libreoffice-convertSimilar Packages:

Npm Package Weekly Downloads Trend

3 Years
🌟 Show real-time usage chart on libreoffice-convert's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of libreoffice-convert](https://npm-compare.com/img/npm-trend/THREE_YEARS/libreoffice-convert.png)](https://npm-compare.com/libreoffice-convert#timeRange=THREE_YEARS)

Cumulative GitHub Star Trend

🌟 Show GitHub stars trend chart on libreoffice-convert's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of libreoffice-convert](https://npm-compare.com/img/github-trend/libreoffice-convert.png)](https://npm-compare.com/libreoffice-convert)

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
libreoffice-convert031021.7 kB53 months agoMIT

README for libreoffice-convert

libreoffice-convert

A simple and fast node.js module for converting office documents to different formats.

Dependency

Please install libreoffice in /Applications (Mac), with your favorite package manager (Linux), or with the msi (Windows) (On Windows, add PROGRAMFILES environment variable for Windows program files path to your local project)

Usage example

'use strict';

const path = require('path');
const fs = require('fs').promises;

const libre = require('libreoffice-convert');
libre.convertAsync = require('util').promisify(libre.convert);

async function main() {
    const ext = '.pdf'
    const inputPath = path.join(__dirname, '/resources/example.docx');
    const outputPath = path.join(__dirname, `/resources/example${ext}`);

    // Read file
    const docxBuf = await fs.readFile(inputPath);

    // Convert it to pdf format with undefined filter (see Libreoffice docs about filter)
    let pdfBuf = await libre.convertAsync(docxBuf, ext, undefined);
    
    // Here in done you have pdf file which you can save or transfer in another stream
    await fs.writeFile(outputPath, pdfBuf);
}

main().catch(function (err) {
    console.log(`Error converting file: ${err}`);
});