如何从ruby中的pdf文件中获取元数据?

时间:2021-05-19 09:01:05

I want to get the metadata from a pdf file in ruby. Not just the date it was created but more like :

我想从ruby中的pdf文件中获取元数据。不仅仅是创建它的日期,更像是:

  • Version
  • Pages
  • Security
  • Created with - [ MOST IMPORTANT ONE ]
  • 创建 - [最重要的一个]

  • CodingSoftware : MAC OS X 10.12.6
  • CodingSoftware:MAC OS X 10.12.6

I have looked at pdfreader but I didnt find a way to extract this from a file

我看过pdfreader,但我没有找到从文件中提取这个的方法

1 个解决方案

#1


0  

Most of this info is accessible with the pdf-reader gem:

大多数信息都可以通过pdf-reader gem访问:

require 'pdf/reader'

PDF::Reader.open("my-file.pdf") do |reader|
  puts reader.info.inspect
  puts reader.metadata.inspect
  puts reader.page_count
  puts reader.pdf_version
end

#1


0  

Most of this info is accessible with the pdf-reader gem:

大多数信息都可以通过pdf-reader gem访问:

require 'pdf/reader'

PDF::Reader.open("my-file.pdf") do |reader|
  puts reader.info.inspect
  puts reader.metadata.inspect
  puts reader.page_count
  puts reader.pdf_version
end