Skip to content

OneLifer/pdf-compress-macos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF Compression Service for macOS

Automatic PDF compression when files are placed in a "hot folder". A zero-touch solution for preparing PDFs for email delivery.

How It Works

  1. Drop PDF into ~/Desktop/PDF-Input folder
  2. Automatically compressed (typically 50-80% size reduction)
  3. Result appears in ~/Desktop/PDF-Output with _compressed suffix
  4. Original is deleted automatically
  5. macOS notification shows compression results

Installation

One-Line Install (Recommended)

Copy and paste this command into your Terminal:

bash <(curl -fsSL https://raw.githubusercontent.com/OneLifer/pdf-compress-macos/main/install.sh)

Alternative: Clone and Install

git clone https://github.com/OneLifer/pdf-compress-macos.git
cd pdf-compress-macos
chmod +x install.sh
./install.sh

Manual Installation

  1. Install dependencies:
brew install ghostscript fswatch
  1. Download and copy the script:
curl -fsSL https://raw.githubusercontent.com/OneLifer/pdf-compress-macos/main/compress-pdf.sh -o /usr/local/bin/compress-pdf.sh
chmod +x /usr/local/bin/compress-pdf.sh
  1. Download and install autostart:
curl -fsSL https://raw.githubusercontent.com/OneLifer/pdf-compress-macos/main/com.user.pdfcompressor.plist -o ~/Library/LaunchAgents/com.user.pdfcompressor.plist
launchctl load ~/Library/LaunchAgents/com.user.pdfcompressor.plist

Compression Quality Settings

Open /usr/local/bin/compress-pdf.sh and change the QUALITY variable:

Value DPI Use Case
screen 72 Minimum size, for screen viewing
ebook 150 Default - balanced quality and size for email
printer 300 For printing
prepress 300 Maximum quality with color preservation

Service Management

Stop:

launchctl unload ~/Library/LaunchAgents/com.user.pdfcompressor.plist

Start:

launchctl load ~/Library/LaunchAgents/com.user.pdfcompressor.plist

Restart:

launchctl unload ~/Library/LaunchAgents/com.user.pdfcompressor.plist
launchctl load ~/Library/LaunchAgents/com.user.pdfcompressor.plist

Check status:

launchctl list | grep pdfcompressor

Logs

All operations are logged to ~/Desktop/PDF-Output/compression.log

Log format:

2024-01-15 14:30:22 - Processing: presentation.pdf (45.32MB)
2024-01-15 14:30:28 - Success: presentation.pdf -> 8.45MB (81% reduction)
2024-01-15 14:30:28 - Deleted original: presentation.pdf

Changing Folders

To change folder locations, edit the variables at the beginning of /usr/local/bin/compress-pdf.sh:

INPUT_DIR="$HOME/Desktop/PDF-Input"
OUTPUT_DIR="$HOME/Desktop/PDF-Output"

After making changes, restart the service.

Uninstallation

launchctl unload ~/Library/LaunchAgents/com.user.pdfcompressor.plist
rm ~/Library/LaunchAgents/com.user.pdfcompressor.plist
rm /usr/local/bin/compress-pdf.sh

Optionally remove the folders:

rm -rf ~/Desktop/PDF-Input ~/Desktop/PDF-Output

Troubleshooting

Homebrew installation requires terminal restart:

If the installer says Homebrew was installed but needs a shell restart:

  1. Close the terminal window
  2. Open a new terminal window
  3. Run the installation command again:
    bash <(curl -fsSL https://raw.githubusercontent.com/OneLifer/pdf-compress-macos/main/install.sh)

Service won't start:

# Check for errors
cat /tmp/pdfcompressor.err

Ghostscript not found:

brew install ghostscript

fswatch not found (polling mode used):

brew install fswatch
# Restart the service

Files are not being processed:

  • Ensure the file has a .pdf or .PDF extension
  • Check the log for errors
  • Verify the service is running: launchctl list | grep pdfcompressor

Requirements

  • macOS 10.14+
  • Homebrew
  • ~100MB for dependencies (Ghostscript, fswatch)

About

Automatic PDF compression for macOS using hot folder

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages