Open Terminal in ubuntu and type following command
Make a much smaller PDF. Note that images will be quite ugly.
The PDF will be a bit smaller. Images remain in good quality.
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/screen -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
gs -sDEVICE=pdfwrite -dPDFSETTINGS=/printer -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
Replace input.pdf with file name and path of your PDF file
gs \ -q -dNOPAUSE -dBATCH -dSAFER \ -sDEVICE=pdfwrite \ -dCompatibilityLevel=1.3 \ -dPDFSETTINGS=/ebook \ -dEmbedAllFonts=true \ -dSubsetFonts=true \ -dAutoRotatePages=/None \ -dColorImageDownsampleType=/Bicubic \ -dColorImageResolution=72 \ -dGrayImageDownsampleType=/Bicubic \ -dGrayImageResolution=72 \ -dMonoImageDownsampleType=/Subsample \ -dMonoImageResolution=72 \ -sOutputFile=output.pdf \ input.pdf
The simplest shell script in the world to shrink your PDFs (as in reduce filesize) under Linux with Ghostscript. Inspired by some code I found in an OpenOffice Python script (I think). It feeds an existing PDF through Ghostscript, downsamples the images to 72dpi, and does some other stuff.
#!/bin/sh gs -q -dNOPAUSE -dBATCH -dSAFER \ -sDEVICE=pdfwrite \ -dCompatibilityLevel=1.3 \ -dPDFSETTINGS=/screen \ -dEmbedAllFonts=true \ -dSubsetFonts=true \ -dColorImageDownsampleType=/Bicubic \ -dColorImageResolution=72 \ -dGrayImageDownsampleType=/Bicubic \ -dGrayImageResolution=72 \ -dMonoImageDownsampleType=/Bicubic \ -dMonoImageResolution=72 \ -sOutputFile=out.pdf \ $1
Then run:
# sh shrinkpdf.sh yourfile.pdf
This produces a shrunken file named out.pdf in the current directory.
Some times users forgot his password then what to do. here many tools available for password break.
We make tutorial for pdf password break as soon as.
You can use Ghost script :
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f YOURFILENAME.pdf
Bulk PDF file compress script
#!/bin/bash
## Script to compress PDF Files using ghostscript incl. subdirs
## Copyright (C) 2016 Maximilian Fries - All Rights Reserved
## Contact: maxfries@t-online.de
## Last revised 2016-07-29
# Usage
# ./pdf-compress.sh [screen|ebook|prepress|default] [verbose]
# Variables and preparation
{
count=0
success=0
successlog=./success.tmp
gain=0
gainlog=./gain.tmp
pdfs=$(find ./ -type f -name "*.pdf")
total=$(echo "$pdfs" | wc -l)
log=./log
verbose="-dQUIET"
mode="prepress"
echo "0" | tee $successlog $gainlog > /dev/null
}
# Are there any PDFs?
if [ "$total" -gt 0 ]; then
#Parameter Handling & Logging
{
echo "-- Debugging for Log START --"
echo "Number of Parameters: $#"
echo "Parameters are: $*"
echo "-- Debugging for Log END --"
} >> $log
# Only compression-mode set
if [ $# -eq 1 ]; then
mode="$1"
fi
# Also Verbose Level Set
if [ $# -eq 2 ]; then
mode="$1"
verbose=""
fi
echo "$pdfs" | while read -r file
do
((count++))
echo "Processing File #$count of $total Files" | tee -a $log
echo "Current File: $file "| tee -a $log
gs \ -q -dNOPAUSE -dBATCH -dSAFER \ -sDEVICE=pdfwrite \ -dCompatibilityLevel=1.3 \ -dPDFSETTINGS=/ebook \ -dEmbedAllFonts=true \ -dSubsetFonts=true \ -dAutoRotatePages=/None \ -dColorImageDownsampleType=/Bicubic \ -dColorImageResolution=72 \ -dGrayImageDownsampleType=/Bicubic \ -dGrayImageResolution=72 \ -dMonoImageDownsampleType=/Subsample \ -dMonoImageResolution=72 \ -sOutputFile="$file-new1" "$file" | tee -a $log
sizeold=$(wc -c "$file" | cut -d' ' -f1)
sizenew=$(wc -c "$file-new" | cut -d' ' -f1)
difference=$((sizenew-sizeold))
# Check if new filesize is smaller
if [ $difference -lt 0 ]
then
rm "$file"
mv "$file-new1" "$file"
printf "Compression was successfull. New File is %'.f Bytes smaller\n" \
$((-difference)) | tee -a $log
((success++))
echo $success > $successlog
((gain-=difference))
echo $gain > $gainlog
else
rm "$file-new"
echo "Compression was not necessary" | tee -a $log
fi
done
# Print Statistics
printf "Successfully compressed %'.f of %'.f files\n" $(cat $successlog) $total | tee -a $log
printf "Safed a total of %'.f Bytes\n" $(cat $gainlog) | tee -a $log
rm $successlog $gainlog
else
echo "No PDF File in Directory"
fi