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, andlibattr - 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.