Back to catalog

PowerPoint to PDF

convert / v1.0.0

Convert PowerPoint files to PDF using LibreOffice.

PDFPowerPointPPTXLibreOfficesofficeConvert

Converts a PowerPoint file or a directory of PowerPoint files to PDF using LibreOffice's soffice command.

Requirements

  • libreoffice
  • soffice

Platforms

LinuxMacOS

Usage

./scripts/pptx-to-pdf.sh -f notes.pptx
./scripts/pptx-to-pdf.sh -i notes.pptx -o notes.pdf
./scripts/pptx-to-pdf.sh --input=notes.pptx
./scripts/pptx-to-pdf.sh --input=notes.pptx --output=notes.pdf
./scripts/pptx-to-pdf.sh -i ./docs

Download

Install quickly or copy a command for your shell.

curl -fsSL "https://raw.githubusercontent.com/PiSaucer/toolbox/main/scripts/pptx-to-pdf.sh" -o "pptx-to-pdf.sh"
wget -O "pptx-to-pdf.sh" "https://raw.githubusercontent.com/PiSaucer/toolbox/main/scripts/pptx-to-pdf.sh"
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/PiSaucer/toolbox/main/scripts/pptx-to-pdf.sh" -OutFile "pptx-to-pdf.sh"

Integrity

SHA256

9208067ec5c0926ff03d077de4f7227ff8c413c7e3d7a645fec3fd430cc0fdc8

Copy and Paste Script

Use this when you want to copy the full script directly.

#!/bin/sh
# pptx-to-pdf.sh
# Copyright (c) 2026 PiSaucer
# Licensed under the MIT License
# Version 1.0.0
# PowerPoint to PDF

# Color codes
# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux
NC='\033[0m' # No Color
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'

helpFunction() {
   echo "PowerPoint to PDF\n"
   echo "Usage: ${YELLOW}$0 -i file -o output${NC}"
   echo "\t-i, -f, --input The Input PowerPoint Filename"
   echo "\t-o, --output The Ouput PDF Filename"
   exit 1 # Exit script after printing help
}

# Parse long options
for arg in "$@"; do
  case $arg in
    --input=*)
      file="${arg#*=}"
      shift
      ;;
    --output=*)
      output="${arg#*=}"
      shift
      ;;
  esac
done

# Parse short options
while getopts "i:f:o:" opt
do
   case "$opt" in
      i ) file="$OPTARG" ;;
      f ) file="$OPTARG" ;; # legacy support
      o ) output="$OPTARG" ;;
      ? ) helpFunction ;; # Print helpFunction in case parameter is non-existent
   esac
done

# Print helpFunction in case parameters are empty
if [ -z "$file" ]
then
   echo "${RED}Missing Input PowerPoint Filename${NC}\n";
   helpFunction
fi

# Check if soffice is installed
if ! command -v soffice >/dev/null 2>&1; then
    printf "${RED}Error: soffice is not installed. Please install LibreOffice first.${NC}\n"
    exit 1
fi

# Determine if input is a file or directory
if [ -d "$file" ]
then
    find "$file" -name "*.pptx" | while read i; do soffice --headless --convert-to pdf "$i"; done
elif [ -f "$file" ]
then
    soffice --headless --convert-to pdf "$file"
    echo "${GREEN}Convert $file to ${output:-$file".pdf"}${NC}"
else
    echo "${RED}Missing Input PowerPoint Filename${NC}";
    helpFunction
fi