Learn how to compress PDFs in Linux to reduce file size.
Learn how to reduce the file size of PDFs on your Linux device using the command line and online resources.
Multi-page PDFs can quickly become too big to email or upload. Luckily, there are a few ways you can compress files to make it easier to handle larger PDFs. Here are the best ways to compress a PDF with Linux.
Linux PDF compression with command line utilities.
If you run Debian or Ubuntu, you can compress PDFs with the Ghostscript command line tool. Ghostscript is software that interprets and compresses certain file types, so your Linux device can read and edit PDFs.
When at work or school, or if you are writing a book, you may want to scan documents and then save them as PDFs. Sometimes these PDFs can be too big or take up too much space on your device, which can make them impractical to send via email or upload to the cloud. Ghostscript can help you compress your PDFs so they are easier to share and store.
Compress PDFs with Ghostscript on Linux.
To compress your PDFs with Ghostscript on Linux, simply follow these steps:
- Install Ghostscript with the command sudo apt install ghostscript.
- Once installed, you can use this command to compress PDF file sizes:
- gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -
- dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -
- sOutputFile=output.pdf input.pdf
- In the command, replace output.pdf and input.pdf with your chosen filenames. The “dPDFSETTINGS” is where you’ll choose the file size.
- Change the suffix =/screen to suit your needs:
- -dPDFSETTINGS=/screen — Low quality and small size at 72dpi.
- -dPDFSETTINGS=/ebook — Slightly better quality but also a larger file size at 150dpi.
- -dPDFSETTINGS=/prepress — High quality and large size at 300 dpi.
- -dPDFSETTINGS=/default — System chooses the best output, which can create larger PDF files.
- Once you input your preferences, simply run the command. Your new compressed PDF will be saved in the same folder as the original.
How to open a PDF file in Linux command line.
If you are wanting to open or view a PDF file while working from the Linux command line, you will need to launch or install Evince on your Linux computer system. Evince is the application that Ubuntu — a Linux operating system — defaults to as its PDF reader.
If you do not have Evince installed on your Linux computer system, you will need to enter the appropriate command line for your operating system version:
- If you are using the Ubuntu Operating System version of Linux, you will need to enter the following command line: $ sudo apt update && sudo apt install evince
- If you are using CentO/Fedora Operating Systems or the latest version of Linux, you will need to enter the following command line: $ sudo dnf install evince
Once Evince is installed on your computer system, you will need to follow these steps to view or open a PDF file from the Linux command line:
- Go to the directory and enter the command line: $ cd downloads. By entering this command, Evince will open for operation.
- Type the command line: $ evince file.pdf. You can also enter: $ evince /Downloads/file.pdf.
- Your PDF will open up and be ready for viewing.
Use an online PDF compressor.
If you’re not comfortable with using the command line, the easiest way to compress a PDF is with an online PDF editor like Adobe Acrobat online services. Simply visit the Acrobat online services website from any web browser and follow three simple steps:
- Navigate to the compress PDF tool.
- Upload your file.
- Select the PDF to compress.
- Download the compressed file to your device.
The online PDF editor will compress the file without losing quality, and you won’t need to download software or enter commands. Another option is to split a PDF into separate files in Linux to isolate the relevant pages.
Discover more about how Acrobat and Acrobat online services can simplify compressing PDFs online from your Linux device.