我不能想到一种纯粹的R方式来做到这一点,但你可以安装你最喜欢的PDF命令行工具(例如,PDF工具包,PDFtk并使用它来获取至少你正在寻找的一些数据) .
以下是使用PDFtk的基本示例.它假定pdftk您的路径可以访问.
x <- getwd() ## I'll run this example in a tempdir to keep things clean
setwd(tempdir())
list.files(pattern="*.txt$|*.pdf$")
# character(0)
pdf(file = "SomeOutputFile.pdf")
plot(rnorm(100))
dev.off()
system("pdftk SomeOutputFile.pdf data_dump output SomeOutputFile.txt")
list.files(pattern="*.txt$|*.pdf$")
# [1] "SomeOutputFile.pdf" "SomeOutputFile.txt"
readLines("SomeOutputFile.txt")
# [1] "InfoBegin" "InfoKey: Creator"
# [3] "InfoValue: R" "InfoBegin"
# [5] "InfoKey: Title" "InfoValue: R Graphics Output"
# [7] "InfoBegin" "InfoKey: Producer"
# [9] "InfoValue: R 3.0.1" "InfoBegin"
# [11] "InfoKey: ModDate" "InfoValue: D:20131102170720"
# [13] "InfoBegin" "InfoKey: CreationDate"
# [15] "InfoValue: D:20131102170720" "NumberOfPages: 1"
# [17] "PageMediaBegin" "PageMediaNumber: 1"
# [19] "PageMediaRotation: 0" "PageMediaRect: 0 0 504 504"
# [21] "PageMediaDimensions: 504 504"
setwd(x)
Run Code Online (Sandbox Code Playgroud)
我将研究其他选项,以指定提取的元数据,并查看是否有一种方便的方法将此信息解析为对您更有用的表单.