PDFs offer us one of the most convenient ways of sharing images.
However, by stuffing tons of data such as images and graphics, the PDF file size can get too big to share via emails.
If you are also suffering from this issue, you have come to the right place.
Whether you’re filling an online form or delivering end-product documentation, everything needs to be done through file sharing. And this file is PDF file, because it is most secure file format out there. It keeps the data on file intact as you can not edit PDF files.
Sometimes it becomes difficult to share or upload PDF file because of size limit restrictions on different websites.
Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform related Linux queries.
In this context, we shall look into how to compress PDF file without compromising with data in it on Ubuntu.
How to Compress PDF Files Using Command Line Method on Ubuntu ?
In command-line method, we’re going to use the tool named ghostscript, for compressing PDF files.
Before proceeding with compression method, make sure you have ghostscript installed on your Ubuntu desktop.
If not, use the following command to install ghostscript:
$ sudo apt-get install ghostscript
Wait for the installation to complete. Now you can use following command to shrink the PDF file size:
$ gs -sDEVICE=pdfwrite -dComatibilityLevel=1.4 – dPDFSETTINGS=/prepress -dNOPAUSE -dQUIT -dBATCH -sOutputFile=compressed_PDF_filename.pdf inputfilename.pdf
Below are the -dPDFSETTINGS options, which you can use according to your need:
i. -dPDFSETTINGS=/screen: for lower quality and smaller size output.
ii. -dPDFSETTINGS=/ebook: better quality with slightly larger file size.
iii. -dPDFSETTINGS=/prepress: high quality output and size.
iv. -dPDFSETTINGS=/printer: output ideal for printer quality.
[ Need urgent Linux related support ? We can help you. ]