Skip to content

Instantly share code, notes, and snippets.

@dimitar-grigorov
Last active May 14, 2021 11:25
Show Gist options
  • Save dimitar-grigorov/5a47d2485eb0110cabe9ba590765c7c6 to your computer and use it in GitHub Desktop.
Save dimitar-grigorov/5a47d2485eb0110cabe9ba590765c7c6 to your computer and use it in GitHub Desktop.

List PDF files print dimensions

Quick and dirty way to list pdf print dimensions in directory structure.

find -name "*.pdf" -o -name "*.PDF" > pdf.txt  
#!/bin/bash
# Depends on imagemagick
while read p; do
  #echo "$p | "
  # identify -verbose "$p" | grep "Print size"
  identify -format "%[i] | %[printsize.x] | %[printsize.y]\n" "$p"
done < pdf.txt

Hints for another ways.

pdfinfo test.pdf | grep "Page size" | grep -Eo '[-+]?[0-9]*\.?[0-9]+' | awk -v x=0.3528 '{print $1*x}'

NB: One dot is 0.3528 mm (0.352777777)

identify -verbose some.pdf | grep "Print size" | grep -Eo '[-+]?[0-9]*\.?[0-9]+' | awk -v x=25.4 '{print $1*x}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment