Closed. This question does not meet Stack Overflow guidelines。它当前不接受答案。












想要改善这个问题吗?更新问题,以便将其作为on-topic用于堆栈溢出。

1年前关闭。



Improve this question




对于我的应用程序,我使用生产和测试服务器(Linux)上的pdfinfo包。现在,我已经设置了本地开发环境,但是我需要安装相同的软件包才能使一切正常运行。我当前缺少的唯一软件包是pdfinfo软件包,似乎很难找到。该软件包在某处可用吗?

最佳答案

您有两个选择,它们将为您提供OS X上PDF文档的信息。

使用Xpdf

最简单地使用Xpdf可以解决您的问题。它可以通过Homebrew获得,并包含pdfinfo:

$ brew search xpdf
homebrew/x11/xpdf
$ brew install homebrew/x11/xpdf
...

然后,您应该能够正常使用pdfinfo:
$ 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

使用MDLS

更一般而言,您可以使用mdls列出与任何文件关联的元数据:
$ 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"

然后,您可以使用-name-raw标志来提取给定的信息,如下所示:
$ mdls -raw -name kMDItemNumberOfPages Main.pdf
10

Source

10-06 05:06