Home > Blockchain >  LIbreOffice - Convert to pdf headless stops working if I send many requests
LIbreOffice - Convert to pdf headless stops working if I send many requests

Time:09-17

I am using LibreOffice 7.1.3.2 10(Build:2) to convert excel(.xlsx) files to pdf files on ubuntu server. I only have CLI version of libre office on the server. I am using node.js and executing the following command for conversion:

libreoffice --headless --convert-to pdf 119.xlsx --outdir /home/pdfs/19

The conversion of the excel to pdf works and the pdf is created successfully. But if I send the request for this conversion many times (for example, 20 requests within 5 minutes), then the pdf is not created. I get no errors from the library either.

How could this be? Could it be something related to the cache or temp folder?


UPDATE:

I checked the processes running on the server using "top" and found a process of soffice that is consuming ~100% of the CPU. Maybe the process is retrying when it encounters an error?

Processes

So I tried to kill the process if there is an error but the process still remains. As long as this process is still running, no other pdf conversions work. Then after sometime (around a few hours) this process stops and only then the pdf conversions start working again.

const child = exec(command, { timeout: 10000, maxBuffer: 20 * 1024 }, (error: any, stdout: any, stderr: any) => {
    if (error) {
          console.log(`error: ${error.message}`);
          console.log(child.pid);
          child.kill();
          return;
    }
    if (stderr) {
          console.log(`stderr: ${stderr}`);
          resolve();
    }
    console.log(`stdout: ${stdout}`);
    resolve();
});

CodePudding user response:

According to the LibreOffice's Bugzilla a similar bug was reported (see https://bugs.documentfoundation.org/show_bug.cgi?id=124798) and it seems to have been fixed with newer versions:

Repro 6.2. No repro 6.3 and 7.2 . Closing.

So I'd suggest upgrading to a newer version.

  • Related