2024-10/cgi-bin/lo2pdf.sh
2024-10-17 08:49:16 +02:00

21 lines
439 B
Bash
Executable file

#!/bin/bash
PATH=/usr/sbin:/bin:/usr/bin:/sbin:/usr/X11R6/bin
HOME=/tmp
echo -e "Content-Type: application/pdf\n"
mkdir -p ${HOME}/lo_pdfs
/usr/bin/soffice \
--headless \
"-env:UserInstallation=file:///tmp/LibreOffice_Conversion_${USER}" \
--convert-to pdf:writer_pdf_Export \
--outdir ${HOME}/lo_pdfs \
${PATH_TRANSLATED}
PDF=$(basename ${PATH_TRANSLATED})
PDF=${PDF%.*}.pdf
cat ${HOME}/lo_pdfs/${PDF}
rm ${HOME}/lo_pdfs/${PDF}