Convert documents through libreoffice (soffice) as a service
- Install, Configure, Run
- System Requirements for Linux
- How to test locally on macOS
git clone git@github.com:savvi-legal/libreoffice-as-a-service.git
pushd ./libreoffice-as-a-service/
echo 'PORT=5227' >> .env
npm ci --only=production
npm run start
# LaaS => 5227
open http://127.0.0.1:5227/
BASE_URL="http://127.0.0.1:5227"
curl -fS "${BASE_URL}"'/api/convert/pdf?filename=Writing1.docx' \
-H 'Content-Type: application/octet-stream' \
--data-binary @'fixtures/Writing1.docx' \
-o Writing1.pdf
Important: -d
is NOT the same as --data-binary
.
- node v16+
- LibreOffice v6.4+
if [[ -z "$(command -v node)" ]]; then
curl -fsSL https://webinstall.dev/node@lts | bash
fi
if [[ -z "$(command -v libreoffice)" ]]; then
sudo add-apt-repository -y ppa:libreoffice/ppa
sudo add-apt-repository -y ppa:libreoffice/libreoffice-6-4
sudo apt-get -y update
sudo apt-get install -y libreoffice
fi
If you install LibreOffice to ~/Applications
, you can add soffice
to your PATH, like so:
- Temporarily add
soffice
to yourPATH
export PATH="/Applications/LibreOffice.app/Contents/MacOS:$PATH"
- Install
pathman
curl https://webinstall.dev/pathman | bash export PATH="${HOME}.local/bin:${PATH}"
- Permanently add
soffice
to yourPATH
pathman add /Applications/LibreOffice.app/Contents/MacOS
Now node
will be able to find soffice
and run it the same as on Linux.
Note: You can also use Webi to install node
:
curl -L https://webinstall.dev/node@lts | bash