/notebook/linux-special-topics/working-with-pdfs-from-the-command-line

Working with pdfs from the command line


Merge pdfs from Bash

sudo apt install -y pdftk
pdftk file1.pdf file2.pdf cat output mergedfile.pdf

from here

Merge using ghostscript:

gs -q -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -sOutputFile=merged.pdf simple1.pdf simple2.pdf simple3.pdf

from here

Shrink a PDF from the command line

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

other compession settings:

  • /screen: lowest
  • /ebook: medium
  • /printer: high
  • /prepress: very high
  • /default: balanced

Convert to PDF-A

gs -dPDFA -dBATCH -dNOPAUSE -sColorConversionStrategy=UseDeviceIndependentColor -sDEVICE=pdfwrite -dPDFACompatibilityPolicy=2 -sOutputFile="outputfile.pdf" "inputfile.pdf"

Tags

About

I am an engineer and educator, having spent ten years as a professor. My goal is to help you build your knowledge of design and technology, get your hardware working, and propel your startup or small business. Get in touch!