libreoffice-convert icon indicating copy to clipboard operation
libreoffice-convert copied to clipboard

How to use filters in the libreoffice-convert

Open nikhilguptagl opened this issue 5 months ago • 2 comments

I am using the basic code which is mentioned here - https://www.npmjs.com/package/libreoffice-convert

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

I want to know what filters can be used and is there any documentation for it ?

nikhilguptagl avatar Sep 10 '24 06:09 nikhilguptagl