Skip to content

Instantly share code, notes, and snippets.

@sharipov-ru
Created October 10, 2012 16:04
Show Gist options
  • Save sharipov-ru/3866572 to your computer and use it in GitHub Desktop.
Save sharipov-ru/3866572 to your computer and use it in GitHub Desktop.
pdf cheatsheet

Compress PDF file with ghostscript

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

Compression levels:

  • screen
  • ebook
  • printer
  • prepress
  • default

Split PDF into separate pages with pdftk

$ for ((i = 0; i <= PAGES_COUNT; i++)); do pdftk input.pdf cat $i output page_$i.pdf dont_ask; done

Merge separate pdf files into one file

$ gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=result.pdf file1.pdf file2.pdf file3.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment