Skip to content
SaveMeClicks

Shrinking a Bloated PDF With Ghostscript Without Wrecking It

A terminal walkthrough for making a smaller, shareable copy of an oversized scan, plus the checks that catch what compression breaks.

Marcus Chen· November 29, 2026

Flat geometric icon of a large stack of square tiles on the left shrinking through arrows into a smaller stack on the right, representing a compressed PDF file.
Shrinking a PDF: a smaller copy, with the original kept safe.

You scanned a stack of paper, and now the PDF is the size of a small moving truck. Your email service says no. This guide shows one way to make a smaller copy with a free command-line tool called Ghostscript, and how to check it before you hit send. It needs a terminal, so it suits a laptop, not a phone.

Start with what you need the file to do

People say "optimize a PDF" and mean four different things. They might want a smaller file, faster viewing on the web, a long-term archive format, or a file with no errors. Ghostscript's own write-up on optimizing PDFs points this out, and it also says advice online sometimes contradicts itself. So pick your goal first.

Your goal here is plain. You want a throwaway sharing copy that stays readable and slips under your recipient's size limit. Nothing in the sources I used gives a number for that limit. Every email provider sets its own, so look up yours. Then do one more thing before you touch anything: keep the original file exactly as it is. If the smaller copy looks bad, you want the real one waiting.

Know what Ghostscript does to your file

Ghostscript does not squeeze your file like a zip folder. It reads the page drawings and images, then builds a brand new PDF from them. The Transloadit guide describes this: the tool takes the drawing steps from your input and writes a fresh document with a preset you choose.

That rebuild explains two warnings. First, the new file can differ from the old one in small ways. Second, the new file can end up bigger than the original. A successful run does not mean a smaller result, so you have to check.

One more catch. A rewritten copy does not keep valid digital signatures. If your PDF is signed, keep the signed original safe and share the copy only when a signature does not matter.

Flat geometric illustration of a calm wide plate: a terminal-style rectangle beside two stacked document shapes, one larger than the other, in muted warm and cool tones on white.
Chapter plate: a terminal window with the Ghostscript command typed in, beside a file list showing the large original scan and a smaller candidate file in a separate review folder.

Choose a preset and run the command

The main control is a preset called PDFSETTINGS. It sets how much Ghostscript shrinks the images and how hard it compresses them. From smallest output to largest, the four presets are:

  • /screen: smallest file, low image resolution.
  • /ebook: medium size and quality.
  • /printer: high resolution, bigger file.
  • /prepress: largest file, print quality.

For a scan full of big page images, start with /ebook. If the file is still too large, try /screen. If text and pictures must stay sharp, try /printer.

Here is the basic command, all on one line:

gs -sDEVICE=pdfwrite -dPDFSETTINGS=/ebook -dNOPAUSE -dBATCH -sOutputFile=output.pdf input.pdf

In plain words, gs starts Ghostscript. The pdfwrite part tells it to write a new PDF. The preset sets the quality. The NOPAUSE and BATCH options stop it from waiting for you after each page. The output name comes after OutputFile, and your original comes last. Give the output a different name from the input. The Ghostscript docs say the two paths must differ, and it keeps your original safe.

Write down your Ghostscript version too. The Transloadit guide tested Ghostscript 10.07.1, and also the older 10.02.1 that ships with Ubuntu 24.04. Noting your version lets you repeat the result later.

Check the result before sharing

Run through this list before you attach anything:

  1. Compare sizes. The new file should be smaller than the original. If it is larger, change the preset or share the original another way.
  2. Scroll through every page. Look at the images, the text, and the layout.
  3. Test the extras one by one: links, bookmarks, searchable text, and document details like title and author.
  4. Check the final size against your email provider's limit.

Step two does not prove step three. Pages can look perfect while the links or searchable text are gone. Click a link. Try searching for a word. The sources I used do not explain how to check the size against a specific limit, so just read the file size in your file manager and compare it with the number you looked up.

Know when this approach is the wrong tool

This method is for a disposable copy whose looks you can check. If your PDF has fillable forms, accessibility tags, a set reading order, embedded attachments, or must meet an archive standard, you need a workflow that keeps and validates those parts. Ghostscript's rebuild can change them.

Also, this is a terminal job. The sources do not cover Windows or macOS steps, and they do not describe a way to do it from a phone. If a command line is not for you, this guide cannot help with that part.

Whatever you do, hold on to the original. The smaller file is only a candidate. It earns its place once it is smaller, readable, and under the limit. Until then, treat it as a draft.

Sources

Shrinking a Bloated PDF With Ghostscript Without Wrecking It | SaveMeClicks