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 "$@"
@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