Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pankaj28843/3ad78df6290b5ba931c1 to your computer and use it in GitHub Desktop.
Save pankaj28843/3ad78df6290b5ba931c1 to your computer and use it in GitHub Desktop.
Make soffice command of Libreoffice work on Mac OS X

Deprecated Notice

This script, originally created on April 29, 2015, addressed a different behavior of LibreOffice installation on macOS at that time. However, it is now outdated and no longer relevant. Please refer to the latest comments for updated information, as much has changed over the past 8–9 years.


Quick Start

sudo curl https://gist.githubusercontent.com/pankaj28843/3ad78df6290b5ba931c1/raw/soffice.sh > /usr/local/bin/soffice && sudo chmod +x /usr/local/bin/soffice

Create a Bash Script at /usr/local/bin/soffice with the Following Content

#!/bin/bash

# This workaround is necessary because a symlink won't work.
# It may complain about missing .plist files.
/Applications/LibreOffice.app/Contents/MacOS/soffice "$@"

Make the Script Executable

sudo chmod +x /usr/local/bin/soffice

Usage

Convert an Excel File to PDF

soffice --headless --convert-to pdf:"calc_pdf_Export" /path/to/some/file.xlsx

This version clarifies the instructions and ensures proper grammar.

#!/bin/bash
# Need to do this because symlink won't work
# It complains about some .plist files
/Applications/LibreOffice.app/Contents/MacOS/soffice "$@"
@rootelement
Copy link

Your paths are missing the L in local.

/usr/loca/bin/soffice

@kirtideshmukh
Copy link

Does this work in latest version ? Because I am not able to locate soffice script under Applications

@florianeck
Copy link

please change /usr/loca/ to /usr/local/ 😄

@dan-maximov
Copy link

Please, change psjinx to your new nickname

@osbre
Copy link

osbre commented Feb 21, 2022

Thanks for the tip, to simplify I just use

/Applications/LibreOffice.app/Contents/MacOS/soffice

@transducer
Copy link

brew install --cask libreoffice also creates a soffice binary.

@FaradayLight
Copy link

Why go to all this trouble when you can create a symlink from a local bin folder in your PATH?

@pankaj28843
Copy link
Author

I’ve updated the README to note the deprecation of this script. It was created years ago to assist a colleague using macOS while the rest of the team worked on Linux at a fast-paced startup.

@Mp5A5
Copy link

Mp5A5 commented Dec 31, 2024

add local path in environment
# libreoffice
export PATH="/Applications/LibreOffice.app/Contents/MacOS:$PATH"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment