Ross Duncan
Ross Duncan

Reputation: 640

How to extract the size of PDF? (Dimensions, not file size)

I have many hundreds of small PDF images (created in Adobe Illustrator) which will be inserted into a Latex document. I need to know the size of these images in real-world dimensions (e.g. 20mm x 14mm), or at least something that Latex can understand.

Is there a command line tool that can produce these dimensions? (I am running Mac OS X.)

A second best solution would some way for Latex to extract the dimensions.

[I have tried pdftk, but its data dump command only seems to tell me the number of pages (1).]

Upvotes: 3

Views: 2069

Answers (2)

Kurt Pfeifle
Kurt Pfeifle

Reputation: 90213

Use pdfinfo or pdfinfo.exe (from the XPDF suite):

pdfinfo ^
   -f 1 ^
   -l 10 ^
   -box ^
   20-pages.pdf

This will extract all the page sizes and all the box info (MediaBox, CropBox, BleedBox, TrimBox, ArtBox) for pages 1 - 10 of the PDF.

Upvotes: 2

Alexey Malistov
Alexey Malistov

Reputation: 26975

Write the following in your LaTeX document:

\setbox0 = \hbox{\includegraphics{small.pdf}}
width = \the\wd0, height = \the\ht0

Upvotes: 0

Related Questions