Science and technology

Shrink PDF dimension with this command line trick

My spouse tutors college students all year long, and lately she wished to assign homework by scanning some workbook pages right into a file and emailing them to her college students. She requested for my assist, so I used Simple Scan, a doc scanning utility for GNOME.

Simple Scan has two decision settings, Images and Text, and saves information as PDFs. Unfortunately, the standard of the scans—the phrases, numbers, and graphics—is unsuitable utilizing the Text setting, however the information are fairly massive—as much as 5MB for just some pages—utilizing the Image setting. I discovered a solution to the latter drawback utilizing the instructions pdf2ps and ps2pdf, that are a part of the Ghostscript package deal. This resolution shrinks the scale of PDF information, making them simpler to share by way of e-mail.

The man pages for these instructions are terse, and it was difficult to seek out good documentation for them and their settings. So I pieced collectively the next by combining info from the person pages with varied different bits of recommendation I discovered on the web.

How to shrink a PDF

First, make a backup of the unique PDF file with a unique title (in case you make an error someplace).

In this instance, I am going to present you shrink a file named Lesson5.pdf. The first step is to transform it to a PostScript file by coming into:

pdf2ps -dLanguageLevel=three Lesson5.pdf

This creates a file named Lesson5.ps, and in case you take a look at its dimension, you is perhaps alarmed. For instance, this instance file was three.1MB as a PDF and ballooned to 29MB as a PS file! Have religion.

Next, enter:

ps2pdf -dPDFSETTINGS=/e book Lesson5.ps

This overwrites your earlier Lesson5.pdf with a smaller file ( cause for making a backup). If you need, you’ll be able to specify one other title for the brand new PDF with:

ps2pdf -dPDFSETTINGS=/e book -sOutputFile=Lesson5b.pdf Lesson5.ps

I discover utilizing the /e book setting for the compression is an effective compromise between file dimension and high quality. In this instance, the compressed PDF was 715KB, about one-fourth the scale of the unique.

Use Ghostscript to compress a PDF

I additionally realized that I can use the gs command to perform every part in a single go:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.four -dPDFSETTINGS=/e book
-dNOPAUSE -dBATCH -dColorImageDecision=150
-sOutputFile=output.pdf someBigFile.pdf

But, wanting on the gs man web page, I do not assume there may be any means I’d have give you this alone. To be taught in regards to the parameters not included within the man web page, discuss with the Ghostscript online documentation.

I believe I am going to stick to the 2 a lot shorter instructions which can be simpler for me to recollect.

Most Popular

To Top