Compressing pdf files in GNU/Linux
Kudus is a RHEL Sysadmin at Google. He has a report for his manager that is a pdf file. The email attachment limit on the email server is 25 MB: the file is currently 125 MB in size. How can Kudus reduce the pdf's file size to <25 MB using the tools available on his RHEL system?
To reduce the PDF file size to less than 25 MB using the tools available on a RHEL system, Kudus can follow these steps:
Install the
ghostscript
package if it's not already installed on the RHEL system. Use the package manager specific to RHEL, such asyum
, to install it. For example:sudo yum install ghostscript
Once
ghostscript
is installed, Kudus can use thegs
command to compress the PDF file. Here's a command he can run:gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
This command uses Ghostscript (
gs
) to compress the PDF file. It sets the compatibility level to 1.4 and the PDFSETTINGS to/ebook
, which is suitable for reading on electronic devices. The resulting file is saved asoutput.pdf
.Please note that reducing the file size may result in some loss of quality or resolution, depending on the content of the PDF file.
After running the command, Kudus can check the resulting file size using the
ls
command:ls -lh output.pdf
The output will display the file size of
output.pdf
.If the resulting file size is still larger than the 25 MB limit, Kudus can experiment with different compression options. For example, he can try different values for the
-dPDFSETTINGS
option, such as/screen
or/printer
, which provide different levels of compression.gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
Kudus can run the command with different PDFSETTINGS values and check the resulting file size to find the best balance between file size and quality.
By following these steps, Kudus can use the ghostscript
tool available on his RHEL system to compress the PDF file and reduce its size to less than 25 MB, making it suitable for email attachment within the given limits.
If Kudus has any further questions or needs additional assistance, please let me know.