Use Libreoffice AppImage as command line

By xngo on June 19, 2019

With Libreoffice AppImage, you can't run the command line options the way that you normally do. This is the limitation on the way Libreoffice AppImage is packaged. Until they correctly package it, all paths supplied need to be in absolute path. Otherwise, it will complain that the file does not exist under the base directory /tmp/.mount_libreoRjHqQH/.

Here are examples showing the old and new way to run Libreoffice from command line.

# Old: Open libreoffice file.
libreoffce my-file.ods.
 
# New: Open libreoffice file.
libreoffice /abosulte/path/to/my-file.ods.
 
# Old: Convert ODT to PDF.
libreoffice --headless --convert-to pdf my-file.odt
 
# New: Convert ODT to PDF: Explicitly set the output directory path.
libreoffice --headless --convert-to pdf  /abosulte/path/to/my-file.odt  --outdir /output/directory/

You can improve the commands above by using readlink to automatically fetch the full path. Here is how you use it.

# Open libreoffice file.
libreoffce $(readlink -ev my-file.ods).
 
# Convert ODT to PDF: Explicitly set the output directory path to current directory.
libreoffice --headless --convert-to pdf  $(readlink -ev my-file.odt) --outdir $(readlink -ev ".")

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.