2021-04-20 00:36:03 +08:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
PATH="/bin/:/usr/bin/"
|
|
|
|
|
2021-03-23 02:32:22 +08:00
|
|
|
# This is a sample script - adjust it per your need
|
|
|
|
# 1 - setup a server with JOD-CONVERTER-REST ( docker run --memory 512m --rm -p 8080:8080 eugenmayer/jodconverter:rest )
|
|
|
|
# 2 - replace the HOST information in below command with your server host
|
2021-03-23 02:48:08 +08:00
|
|
|
|
2021-04-13 21:41:16 +08:00
|
|
|
# This script receives three params
|
2021-03-23 02:48:08 +08:00
|
|
|
# Param 1: Input office file path (e.g. "/tmp/test.odt")
|
|
|
|
# Param 2: Output pdf file path (e.g. "/tmp/test.pdf")
|
2021-04-13 21:41:16 +08:00
|
|
|
# Param 3: Destination Format (pdf default)
|
2021-03-23 02:48:08 +08:00
|
|
|
|
2021-04-20 00:36:03 +08:00
|
|
|
if (( $# == 0 )); then
|
|
|
|
echo "Missing parameter 1 (Input office file path)";
|
|
|
|
exit 1
|
|
|
|
elif (( $# == 1 )); then
|
|
|
|
echo "Missing parameter 2 (Output pdf file path)";
|
|
|
|
exit 1
|
|
|
|
fi;
|
|
|
|
|
|
|
|
|
2021-04-27 04:38:30 +08:00
|
|
|
source="$1"
|
|
|
|
dest="$2"
|
2021-04-20 00:36:03 +08:00
|
|
|
|
2021-04-13 21:41:16 +08:00
|
|
|
#If output format is missing, define PDF
|
|
|
|
convertTo="${3:-pdf}"
|
|
|
|
|
2021-04-27 04:38:30 +08:00
|
|
|
curl -X POST "http://127.0.0.1:8080/lool/convert-to/$convertTo" -H "accept: application/octet-stream" -H "Content-Type: multipart/form-data" -F "data=@${source}" > "${dest}"
|
2021-03-23 02:48:08 +08:00
|
|
|
|
|
|
|
exit 0
|