Skip to content

Instantly share code, notes, and snippets.

@luca-c-xcv
Last active February 25, 2022 12:54
Show Gist options
  • Save luca-c-xcv/1f48bf13408ba5fbbc0f9c5281ced9b6 to your computer and use it in GitHub Desktop.
Save luca-c-xcv/1f48bf13408ba5fbbc0f9c5281ced9b6 to your computer and use it in GitHub Desktop.
PDF: Useful

Merge PDFs

Requires

  • poppler-utils package: sudo apt install poppler-utils

Execution

  • merge pdf: pdfunite <pdf-files> <output-file>.pdf (the list of PDFs must be ordered in ascending order)

Change PDF quality

Requires

  • Ghostscript tool: sudo apt install ghostscript

Execution

gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/<type> -dNOPAUSE -dQUIET -dBATCH -sOutputFile=<output-path>.pdf <input-path>.pdf

type

  • screen: 72 dpi
  • ebook: 150 dpi
  • prepress: 300 dpi
  • printer: 300 dpi
  • default

Images to PDF

Requires

  • ImageMagick tool: sudo apt install imagemagick

Execution

convert ./*.<ext> <output>.pdf

ext

ext represents the extantion of images such as jpg, png and so on

(for more options run convert -h)

Extract pages from a PDF

Requires

  • PDFtk tool: sudo snap install pdftk

Execution

pdftk <input-path-file>.pdf cat <page-range> output <output-path-file>.pdf

page-range

page range represents a page range or a single, e.g. '1-7' extracts pages 1 through 7 or '5' extracts only page 5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment