elwerene / libreoffice-convert

MIT License
241 stars 94 forks source link

why i got this? #97

Closed ownlight6 closed 8 months ago

ownlight6 commented 1 year ago

F:\LH\lightTools\node_modules\rimraf\rimraf.js:310 throw er ^

Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\LQ\AppData\Local\Temp\libreofficeConvert_-292-DszZA0c1ISgY' at Object.rmdirSync (node:fs:1227:10) at rmkidsSync (F:\LH\lightTools工具\node_modules\rimraf\rimraf.js:349:27) at rmdirSync (F:\LH\lightTools工具\node_modules\rimraf\rimraf.js:329:7) at rimrafSync (F:\LH\lightTools工具\node_modules\rimraf\rimraf.js:301:9) at Object._cleanupCallback [as removeCallback] (F:\LH\lightTools工具\node_modules\tmp\lib\tmp.js:356:16) at F:\LH\lightTools工具\node_modules\libreoffice-convert\index.js:63:17 at wrapper (F:\LH\lightTools工具\node_modules\async\dist\async.js:271:20) at F:\LH\lightTools工具\node_modules\async\dist\async.js:1143:21 at F:\LH\lightTools工具\node_modules\async\dist\async.js:327:20 at F:\LH\lightTools工具\nodemodules\libreoffice-convert\index.js:39:32 { errno: -4051, syscall: 'rmdir', code: 'ENOTEMPTY', path: 'C:\Users\LQ\AppData\Local\Temp\libreofficeConvert-292-DszZA0c1ISgY' }

async function docx2pdf() {
    try {
        const ext = '.pdf'
        const inputPath = path.join(__dirname, '/input/docx2pdf.docx');
        const outputPath = path.join(__dirname, `/output/docx2pdf${ext}`);
        const docxBuf = fs.readFileSync(inputPath);
        let pdfBuf = await libre.convertAsync(docxBuf, ext, undefined);
        console.log(pdfBuf)
        fs.writeFileSync(outputPath, pdfBuf);
    } catch (err) {
        console.log(err)
    }
}
xiaoshuoyiyi commented 1 year ago

I have the same problem

waseem8449 commented 1 year ago

same issue

Arthemis97 commented 1 year ago

Unsupported character in your docx file.

nanchengjiumeng commented 9 months ago

same error

rifkidocs commented 9 months ago

same error

zyz9740 commented 8 months ago

At first, two similar issues have been closed here. https://github.com/elwerene/libreoffice-convert/issues/87 https://github.com/elwerene/libreoffice-convert/issues/28

https://github.com/elwerene/libreoffice-convert/issues/87 reminders me that I should check the dependency.

There is a misleading in the download page image

Please install the right package named LibreOffice_7x.x.x_Win_x86-64.msi. image

I installed the wrong package thus causing the same error. After installing the right package, it disappeared.

ShadowSlayer03 commented 8 months ago

Same error here while trying to use the package. Full Error: Error: ENOTEMPTY: directory not empty, rmdir 'C:\Users\arjun\AppData\Local\Temp\libreofficeConvert_-3868-5cYxdfMS9i7B' at Object.rmdirSync (node:fs:1229:10) at rmkidsSync (C:\Users\arjun\Documents\Web Dev Angela\Code It Yourself\PDF Merger and Converter\node_modules\rimraf\rimraf.js:349:27) at rmdirSync (C:\Users\arjun\Documents\Web Dev Angela\Code It Yourself\PDF Merger and Converter\node_modules\rimraf\rimraf.js:329:7) at rimrafSync (C:\Users\arjun\Documents\Web Dev Angela\Code It Yourself\PDF Merger and Converter\node_modules\rimraf\rimraf.js:301:9) at Object._cleanupCallback [as removeCallback] (C:\Users\arjun\Documents\Web Dev Angela\Code It Yourself\PDF Merger and Converter\node_modules\tmp\lib\tmp.js:356:16) at C:\Users\arjun\Documents\Web Dev Angela\Code It Yourself\PDF Merger and Converter\node_modules\libreoffice-convert\index.js:63:17 at wrapper (C:\Users\arjun\Documents\Web Dev Angela\Code It Yourself\PDF Merger and Converter\node_modules\async\dist\async.js:271:20) at C:\Users\arjun\Documents\Web Dev Angela\Code It Yourself\PDF Merger and Converter\node_modules\async\dist\async.js:1143:21 at C:\Users\arjun\Documents\Web Dev Angela\Code It Yourself\PDF Merger and Converter\node_modules\async\dist\async.js:327:20 at C:\Users\arjun\Documents\Web Dev Angela\Code It Yourself\PDF Merger and Converter\nodemodules\libreoffice-convert\index.js:39:32 { errno: -4051, syscall: 'rmdir', code: 'ENOTEMPTY', path: 'C:\Users\arjun\AppData\Local\Temp\libreofficeConvert-3868-5cYxdfMS9i7B' I even went to the path and opened it to see that it was empty, maybe hidden files or smthng but there was nothing to delete manually.

mihir254 commented 8 months ago

Came across the same issue on windows. Installed LibreOffice and checked the file path mentioned in the node module to make it work. Code looks like: const libre = require('libreoffice-convert'); libre.convertAsync = require('util').promisify(libre.convert); const pdfBuf = await libre.convertAsync(doc.getZip().generate({ type: "nodebuffer", mimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", }), 'pdf', undefined);

And then I proceeded with using the buffer according to my use case. Thank you for sharing the resources in the above comments, it helped a lot! Cheers!