问题描述
因此,我正在使用libreoffice-convert,它当然在我的nodejs应用程序中运行。 我的代码如下
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);
});
The application cannot be started.
The configuration file "C:\Program Files\LibreOffice\program\bootstrap.ini" is corrupt.
这是我的bootstrap.ini
[Bootstrap]
InstallMode=<installmode>
ProductKey=LibreOffice 7.0
UserInstallation=$SYSUSERCONfig/LibreOffice/4
如果有人可以帮助解决此问题,请多谢。同样不确定是否有帮助,但是我正在Windows上运行它。
解决方法
libreoffice-convert
中存在一个已知问题,但仍处于Open
状态:issue。您可以在此问题评论的讨论中尝试解决方法
在 libreoffice-convert/index.js 中做以下更改
// change
let command = `${results.soffice} -env:UserInstallation=file://${installDir.name} --headless --convert-to ${format}`;
// to
let command = `${results.soffice} --headless --convert-to ${format}`;
,
如果有人遇到和我一样的问题,这就是我为解决它所做的。
- 下载并安装 LibreOffice。你可以下载它here
- 运行
npm i libreoffice-convert
后,转到your_project/node_modules/libreoffice-convert/index.js
,找到下面的代码。
/* your_project/node_modules/libreoffice-convert/index.js */
let command = `-env:UserInstallation=file://${installDir.name} --headless --convert-to ${format}`;
// change to
let command = `${installDir.name} --headless --convert-to ${format}`;
- 立即尝试您的脚本。