Gice

Technology and General Blog

When you have a significant PDF file or a massive number of PDF files to transfer, it is a much better practice to compress PDF data files. In Linux, there are many methods for compressing the PDF files like command-line applications and GUI equipment for no cost.

This submit will have a quick and step-by-move tutorial on how to compress a PDF file in Linux for absolutely free by the command line working with GhostScript. GhostScript’s installation system and utilization strategy are shown on the Ubuntu 20.04 LTS method, and it can perform on just about every other Debian-dependent working method.

Compress PDF File in Linux Applying GhostScript

Ghost Script is a command-line utility utilized for compressing the PDF data files and for accomplishing other PDF-relevant duties.

Installation of GhostScript

To put in GhostScript on Ubuntu or other Debian-dependent running devices, it is a superior observe to update and upgrade the system’s offers.

$ sudo apt update && sudo apt up grade -y

Execute the command furnished down below to start off the set up of GhostScript:

$ sudo apt put in ghostscript

The GhostScript will be mounted, and after the effective installation of Ghostscript, it is time to realize the utilization of GhostScript in Ubuntu.

Usage of Ghost Script Command

The syntax for compressing a PDF file utilizing the GhostScript command is provided under:

$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Most of the alternatives will need to keep as they are our worry is with only two solutions:

-dPDFSETTINGS Solution

For higher-excellent 300 DPI output, use /prepress placing.

For medium-high-quality output around 150 DPI, use /e book placing.

For low-high-quality output around 72 DPI, use /screen location.

-s OutputFile selection

Provide the title of the output file that you want to give.

And lastly, at the close of the command, produce down the PDF file you have to have to compress.

Just after executing the GhostScript command for compressing the PDF file, you will get the compressed PDF file inside of a number of seconds based mostly on the file size presented.

Case in point

Suppose we have a file.pdf in the downloads directory and we want to compress it, go to the distinct directory where by the file is placed.

Execute the GhostScript command offered down below to compress the file.pdf:

$ gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/monitor -dNOPAUSE -dQUIET -dBATCH -sOutputFile=compressed.pdf file.pdf

Do not overlook to transform the PDF settings according to your alternative. Enter file identify, and output file.

Once the file is compressed, execute the command provided beneath to watch the transform in the sizing of the two information:

You can verify that the compressed file is scaled-down in sizing as in contrast to the initial PDF file.

Summary

GhostScript is a command-line resource utilised for compressing PDF information in Linux. In this article, we have learned how to install the GhostScript on Ubuntu, how to compress a PDF file applying the GhostScript, and how to use it and change configurations to extract the compressed PDF of our possess preference.

Leave a Reply

Your email address will not be published. Required fields are marked *