In a moment: Find out how to reduce the size of a PDF file on Linux. Command line and GUI methods were discussed.
I completed an application form and asked to download the required documents in PDF format. That’s good. I collected all the scanned images and merged them into a PDF file using the gscan2pdf tool.
The problem occurred when I tried to download this PDF file. The download failed because the maximum file size was exceeded. It just meant that I had to reduce the size of the PDF file somehow.
You can now use the online website for PDF compression, but I don’t trust them. Uploading a file containing important documents to an unknown server is not a good idea. You can never be sure that they will not keep a copy of the downloaded PDF document.
That’s why I prefer compressing PDF files on my system rather than uploading them to any server.
In this short guide I will show you how to reduce the size of PDF files under Linux. I’ll show you the command line and GUI methods.
Method 1: Reducing the size of the PDF file on the Linux command line
You can use the Ghostscript command line to compress a PDF file. Most Linux distributions already contain an open version of Ghostscript. However, you can always try to install it, just to be sure.
For Debian/Ubuntu-based distributions, use the following command to install Ghostscript
install sudo apt ghostscript
Now that you are sure that Ghostscript is installed, you can use the following command to reduce the size of the PDF file:
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/prepress -dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed_PDF_file.pdf input_PDF_file.pdf
In the above command, you must add the correct path to the source and enter a PDF file.
The team looks scared and confused. I suggest you copy and paste most of it. What you need to know is the parameter dPDFSETTINGS. This determines the level of compression and therefore the quality of your compressed PDF file.
|/press (default setting)||Products of better quality (300 dpi), but larger in size.|
|/Album||Average quality (150 dpi) output file size|
|/Screen||Low output quality (72 dpi), but smallest possible size of the output file|
Don’t forget that some PDF files cannot be compressed or can be compressed only slightly. Applying compression to some PDF files may even result in a larger file than the original. There is not much to do in such cases.
Method 2: PDF Compression under Linux usingGUI
I understand not everyone is familiar with the command line tool. PDF editors on Linux are not very useful when it comes to compression. That’s why It’s FOSS has been working on creating the GUI version of the Ghostscript command you saw above.
Panos from It’s FOSS worked on the creation of a Python-Qt based GUI wrapper for Ghostscript. The tool provides you with a simple interface where you can select your input file, choose the compression level and click the compression button to compress the PDF file.
The compressed PDF file is saved in the same folder as the original PDF file. Your original PDF file remains intact. The compressed file is renamed by adding -compressed to the original filename.
If you are not satisfied with the compression, you can select a different compression level and compress the file again.
The source code of the PDF compressor can be found in our GitHub repository. To facilitate the use of the tool, we have presented it as an AppImage. This manual explains how to use AppImage.
Keep in mind that the instrument is still in an early stage of development. You might be in trouble. If you do, please let us know in the comments or, better yet, report the error here.
We will try to add other packages (Snap, Deb, PPA etc.) to future releases. If you have experience in designing and packaging, you are welcome to help us.
Would you like the FOSS team to work on the development of other such small desktop programs in the future? We look forward to your feedback and suggestions.
Do you like what you read? Please share it with others.linux mint compress pdf,compress pdf to 100kb,linux pdf shrinker,ghostscript compress pdf,how to reduce file size in linux,pdf compressor command line,command line tool compress pdf,make a pdf smaller linux