elwerene / libreoffice-convert

MIT License
242 stars 94 forks source link

Cannot run the example #14

Closed Nefroz closed 4 years ago

Nefroz commented 4 years ago

Hello, I've been trying to run the "Usage Example", first I've had an error with the 2 const having the same name, renamed one, but then I think there's something not working somewhere because when I test it with Postman I get a simple file with name: xxxxxxx{extend}

Here is the code:

const path = require("path"); const fs = require("fs"); const multiparty = require("multiparty"); const util = require("util"); const { exec } = require('child_process'); const libre = require('libreoffice-convert');

exports.postfile =(req,res,next) =>{ const extend = '.png'; const input = path.join(dirname, '../core/ressources/images/test.pdf'); const outputPath = path.join(dirname, ../core/ressources/images/test{extend});

const enterPath = fs.readFileSync(input);
libre.convert(enterPath, extend, undefined, (err, done) => {
    if (err) {
        console.log(`Error converting file: ${err}`);
    }
    fs.writeFileSync(outputPath, done);
});

}); };

elwerene commented 4 years ago

Your code is not well formated. did you miss the $ in your path.join of outputPath?