This article covers how you can compress the PDF file size in Linux and its distributions like Ubuntu.
Although applications like LibreOffice Writer allow you to convert your business documents into portable and secure PDFs, sometimes the files they produce are too large and unwieldy. These huge files may hog network bandwidth, waste space on company storage devices or be too big to share as email attachments.
Fortunately, Ubuntu provides a complicated, but efficient method to reduce the size of your PDFs using the standard Ghostscript library of command line utilities.
How to use Ghostscript command to compress PDF file in Linux Systems ?
You can use Ghostscript command line tool for compressing a PDF file.
Most Linux distributions include the open source version of Ghostscript already.
However, you can still try to install it just to make sure.
On Debian/Ubuntu based distributions, use the following command to install Ghostscript:
$ sudo apt install ghostscript
1. Start a Ubuntu terminal session and navigate to the folder containing the PDF file you want to shrink.
2. PDF is in the Documents folder, type "cd Documents" (without the quotation marks) at the terminal prompt and press "Enter."
3. Type the Ghostscript command to reduce the size of your PDF file. For example, if your file is named "mydoc.pdf" and you want the reduced version to be called "mydocsmaller.pdf," type the following command at the terminal prompt as a single line:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=mydocsmaller.pdf mydoc.pdf
This command instructs the Ghostscript GS utility to take the file "mydoc.pdf" and create a version 1.4-compatible, low-resolution PDF file called "mydoc_smaller.pdf" that is optimized to be displayed on your PC screen rather than printed on paper.