Mac OS X now supports the Pdfinfo package

So You can get number of pages with:
Question:
I have many hundreds of small PDF images (created in Adobe Illustrator) which will be inserted into a Latex document. It is available via Homebrew and contains
:
You should then be able to use
as normal:
Using mdls
More generally, you could use mdls to list the metadata associated with
any
file:
You can then use the
and
flags to extract a given piece of informations like this:
Source
Question:
How can I output the number of pages in a PDF in the Terminal?

Question:

I utilize the
pdfinfo
package on both my production and test servers (both running Linux) for my application. However, I now need to install the same packages in my local development environment to ensure everything works smoothly. Unfortunately, the only package that seems to be missing is the
Pdfinfo
package, and I am having difficulty locating it. Can anyone direct me to where I can find this package?


Solution:


There are two options available to obtain the details of a PDF document on OS X.


Using Xpdf

The optimal solution to your issue can be found through Xpdf, which can be easily accessed through Homebrew. Xpdf includes

pdfinfo

among its features.

$ brew search xpdf
xpdf
$ brew install xpdf
...

Afterward, you will be capable of utilizing the

pdfinfo

as you typically would.

$ pdfinfo Main.pdf
Title:          Title
Subject:        Some subject
Keywords:       
Author:         Joe A. Bloggs
Creator:        LaTeX with hyperref package
Producer:       pdfTeX-1.40.16
CreationDate:   Tue Apr 12 18:59:38 2016
ModDate:        Tue Apr 12 18:59:38 2016
Tagged:         no
Form:           none
Pages:          10
Encrypted:      no
Page size:      595.276 x 841.89 pts (A4) (rotated 0 degrees)
File size:      60057 bytes
Optimized:      no
PDF version:    1.5


Using mdls

In a broader sense, mdls can be utilized to enlist the metadata linked with every file.

$ mdls Main.pdf
kMDItemAuthors                 = (
    "Joe A. Bloggs"
)
kMDItemContentCreationDate     = 2016-04-12 17:56:08 +0000
kMDItemContentModificationDate = 2016-04-12 17:59:39 +0000
kMDItemContentType             = "com.adobe.pdf"
kMDItemContentTypeTree         = (
    "com.adobe.pdf",
    "public.data",
    "public.item",
    "public.composite-content",
    "public.content"
)
kMDItemCreator                 = "LaTeX with hyperref package"
kMDItemDateAdded               = 2016-04-12 17:56:08 +0000
kMDItemDescription             = "Some subject"
kMDItemDisplayName             = "Main.pdf"
kMDItemEncodingApplications    = (
    "pdfTeX-1.40.16"
)
kMDItemFSContentChangeDate     = 2016-04-12 17:59:39 +0000
kMDItemFSCreationDate          = 2016-04-12 17:56:08 +0000
kMDItemFSCreatorCode           = ""
kMDItemFSFinderFlags           = 0
kMDItemFSHasCustomIcon         = (null)
kMDItemFSInvisible             = 0
kMDItemFSIsExtensionHidden     = 0
kMDItemFSIsStationery          = (null)
kMDItemFSLabel                 = 0
kMDItemFSName                  = "Main.pdf"
kMDItemFSNodeCount             = (null)
kMDItemFSOwnerGroupID          = 20
kMDItemFSOwnerUserID           = 501
kMDItemFSSize                  = 60057
kMDItemFSTypeCode              = ""
kMDItemKind                    = "Portable Document Format (PDF)"
kMDItemLastUsedDate            = 2016-04-12 18:00:54 +0000
kMDItemLogicalSize             = 60057
kMDItemNumberOfPages           = 10
kMDItemPageHeight              = 841.89
kMDItemPageWidth               = 595.276
kMDItemPhysicalSize            = 61440
kMDItemSecurityMethod          = "None"
kMDItemTitle                   = "Title"
kMDItemUseCount                = 3
kMDItemUsedDates               = (
    "2016-04-11 23:00:00 +0000"
)
kMDItemVersion                 = "1.5"

Afterward, you can retrieve specific information by utilizing the flags

-name

and

-raw

.

$ mdls -raw -name kMDItemNumberOfPages Main.pdf
10

Source

Frequently Asked Questions