Skip to content

Reduce size of PDF (compress) using GhostScript at bash terminal

Notifications You must be signed in to change notification settings

jishanshaikh4/shrinkpdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 

Repository files navigation

Shrinkpdf

CodeFactor

Reduce size of PDF (compress) using Ghostscript at terminal.

Execution

Move the shrinkpdf.sh to your system execution folder (e.g. /bin/ in Linux distro). Give it permissions to execute

chmod +x ~/bin/shrinkpdf.sh

First parameter (input.pdf): filename of the PDF that is to be converted

Second parameter (output.pdf): filename of the converted PDF

Third parameter: The DPI (resolution) for the output PDF. Default value: 72. For more compression, lower DPI is better but the quality will be worse.

Run it as follows:

~/bin/shrinkpdf.sh input.pdf output.pdf

~/bin/shrinkpdf.sh input.pdf output.pdf 100

~/bin/shrinkpdf.sh input.pdf output.pdf 120

If you don't want to install shrinkpdf in the system, just run

bash shrinkpdf.sh input.pdf output.pdf 72

Credits

https://bash.cyberciti.biz/file-management/linux-shell-script-to-reduce-pdf-file-size/