elwerene / libreoffice-convert

MIT License
241 stars 94 forks source link

PDF page formatting issue #44

Closed dhrupadv closed 3 years ago

dhrupadv commented 3 years ago

PDF page formatting issue ex:- DOCX file upload with single page

san-valley-assisted-living-p2-evacuation_plan (2).docx

it's generate pdf with two pages like above EX

san-valley-assisted-living-p2-evacuation_plan-(2) (1).pdf


const libre = require('libreoffice-convert');

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

const extend = '.pdf' const enterPath = path.join(dirname, '/resources/example.docx'); const outputPath = path.join(dirname, /resources/example${extend});

// Read file const file = fs.readFileSync(enterPath); // Convert it to pdf format with undefined filter (see Libreoffice doc about filter) libre.convert(file, extend, undefined, (err, done) => { if (err) { console.log(Error converting file: ${err}); }

// Here in done you have pdf file which you can save or transfer in another stream
fs.writeFileSync(outputPath, done);

});

elwerene commented 3 years ago

As this lib only calls libreoffice, you should probably open an issue there