Site Map - skip to main content

Hacker Public Radio

Your ideas, projects, opinions - podcasted.

New episodes Monday through Friday.

hpr2708 :: Ghostscript

Klaatu talks about manipulating PDFs with gs and pdf-stapler

<< First, < Previous, Latest >>

Hosted by Klaatu on Wednesday 2018-12-19 is flagged as Clean and is released under a CC-BY-SA license.
Tags: pdf, ebook, bloat, print.

Listen in ogg, spx, or mp3 format. | Comments (2)

Part of the series: Privacy and Security

In this open series, you can contribute shows that are on the topic of Privacy and Security

Ghostscript is the open source implementation of Postscript. You can read its docs online.

To compress a big PDF into something possibly smaller:

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

That renders basically the same PDF with all images down-res'd to 72 DPI. Other valid setting profiles are ebook, printer, and prepress.

To render a version of a PDF without any raster images in it, making it cheaper and faster to print:

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dBATCH -dFILTERIMAGE -sOutputFile=output.pdf example.pdf

The FILTERIMAGE option drops raster images from the file. The FILTERVECTOR option filters vector images, and FILTERTEXT filters text.

If pdftk is not available for your OS, you can use pdf-stapler instead for cutting and concatenating PDF files. It doesn't deal with metadata as well as pdftk does, however.

It's worth noting that pdftk is available as a snap package

It's also worth noting that this is actually episode 2 in a series about steganography.

Show Transcript

Automatically generated using whisper

whisper --model tiny --language en hpr2708.wav

<< First, < Previous, Latest >>


Subscribe to the comments RSS feed.

Comment #1 posted on 2019-02-07T23:05:08Z by Steve

Just what I needed

Just wanted to say thank you for this episode. I needed to reduce the size of a PDF today, and I knew right where to come and the necessary command was in the show notes. Worked perfectly.

Comment #2 posted on 2019-03-07T18:49:22Z by Klaatu

You're welcome

I'm glad this helped, Steve.

You're not the only one this episode has helped. I've referred back to it at least fortnightly since posting it!

<< First, < Previous, Latest >>

Leave Comment

Note to Verbose Commenters
If you can't fit everything you want to say in the comment below then you really should record a response show instead.

Note to Spammers
All comments are moderated. All links are checked by humans. We strip out all html. Feel free to record a show about yourself, or your industry, or any other topic we may find interesting. We also check shows for spam :).

Provide feedback
Your Name/Handle:
Anti Spam Question: What does the P in HPR stand for ?
Are you a spammer →
Who hosted this show →
What does HPR mean to you ?