Error: source file could not be loaded when converting libreoffice --headless --convert-to pdf --outdir /tmp something.dxf

I am using LibreOffice in headless mode inside a Docker container to convert DXF files to PDF from a Ruby on Rails API.
The same DXF file sometimes converts successfully and sometimes fails with the following error:

LibreOffice Exit Code: 0
LibreOffice stdout:
LibreOffice stderr: Error: source file could not be loaded

The DXF file exists, is readable, and has a size of approximately 415 KB. The failure occurs even though LibreOffice returns exit code 0 .

My conversion code is:
Title: Intermittent DXF-to-PDF Conversion Failure in Headless LibreOffice with Parallel Requests

Hello LibreOffice Community,

I am using LibreOffice in headless mode inside a Docker container to convert DXF files to PDF from a Ruby on Rails API.

The same DXF file sometimes converts successfully and sometimes fails with the following error:

LibreOffice Exit Code: 0
LibreOffice stdout:
LibreOffice stderr: Error: source file could not be loaded

The DXF file exists, is readable, and has a size of approximately 415 KB. The failure occurs even though LibreOffice returns exit code 0.

My conversion code is:

pdf_file_path = "#{out_dir}/#{dxf_file_path.split('/').last.gsub(/\.dxf/, '.pdf')}"

convert_command =
  "libreoffice --headless --convert-to pdf --outdir #{out_dir} #{dxf_file_path}"

Rails.logger.debug "LibreOffice Command: #{convert_command}"

success_pdf = false

1000.times do
  Rails.logger.debug "PDF exists? #{File.exist?(pdf_file_path)}"
  break if File.exist?(pdf_file_path)

  pdf_stdout, pdf_stderr, pdf_status =
    Open3.capture3(convert_command)

  Rails.logger.debug "LibreOffice Exit Code: #{pdf_status.exitstatus}"
  Rails.logger.debug "LibreOffice stdout: #{pdf_stdout}"
  Rails.logger.debug "LibreOffice stderr: #{pdf_stderr}"

  sleep 0.01
end

Environment:

  • Application: Ruby on Rails API
  • Execution environment: Docker container
  • Conversion mode: LibreOffice headless
  • Installed packages: libreoffice, libreoffice-base, libreoffice-lang-ja, and libattr
  • Multiple POST requests can be processed concurrently.
  • The same DXF file can succeed in one request and fail in another.

I want to understand the root cause rather than simply suppressing the error message.

Thank you for your help.

To narrow down the cause, could you clarify a few points?

  1. By “fails”, do you mean that the PDF is never created in the end? Or is the PDF created, but an error appears in stderr?
  2. Could you post the complete debug log for one failed request, without omitting anything?
  3. Can multiple conversions run at the same time? Does the error also occur when requests are processed one at a time?
  4. Please share the FROM line of your Dockerfile and the output of libreoffice --version.

Also, the 6.4 series reached end of life in November 2020. I recommend using a newer version.
https://wiki.documentfoundation.org/ReleasePlan/6.4