Try wget https://bash.commongrounds.cc/uploads/1752097285_PDf.sh
from the console
#!/bin/bash # Check if Ghostscript is installed if ! command -v gs &> /dev/null; then echo "Error: Ghostscript is not installed. Please install it first." exit 1 fi # Check if an input file is provided if [ $# -ne 1 ]; then echo "Usage: $0 input.pdf" exit 1 fi input_file="$1" output_file="optimized_$(basename "$input_file")" # Verify input file exists and is a PDF if [ ! -f "$input_file" ]; then echo "Error: Input file '$input_file' does not exist." exit 1 fi # Prompt for PDF title read -p "Enter the PDF title: " pdf_title # Optimize PDF using Ghostscript with aggressive compression settings gs \ -sDEVICE=pdfwrite \ -dCompatibilityLevel=1.4 \ -dPDFSETTINGS=/screen \ -dColorImageDownsampleType=/Bicubic \ -dColorImageResolution=72 \ -dGrayImageDownsampleType=/Bicubic \ -dGrayImageResolution=72 \ -dMonoImageDownsampleType=/Subsample \ -dMonoImageResolution=72 \ -dColorImageDownsampleThreshold=1.0 \ -dGrayImageDownsampleThreshold=1.0 \ -dMonoImageDownsampleThreshold=1.0 \ -dCompressPages=true \ -dCompressFonts=true \ -dSubsetFonts=true \ -dEmbedAllFonts=false \ -dOptimize=true \ -dAutoRotatePages=/None \ -dBATCH \ -dNOPAUSE \ -sOutputFile="$output_file" \ -c "[/Title ($pdf_title) /DOCINFO pdfmark" \ -f "$input_file" # Check if optimization was successful if [ $? -eq 0 ]; then echo "Optimization complete. Output saved as '$output_file'." # Display file sizes original_size=$(stat -f%z "$input_file" 2>/dev/null || stat -c%s "$input_file") optimized_size=$(stat -f%z "$output_file" 2>/dev/null || stat -c%s "$output_file") echo "Original size: $original_size bytes" echo "Optimized size: $optimized_size bytes" reduction=$(( (original_size - optimized_size) * 100 / original_size )) echo "Size reduction: $reduction%" else echo "Error: PDF optimization failed." exit 1 fiBASH to Home