如何在ruby上获取现有pdf的总页数?

时间:2023-02-09 15:52:01

How to get the total number of pages of the existing pdf in rails?

如何获取rails中现有pdf的总页数?

1 个解决方案

#1


19  

You can use pdf-reader (also available as a ruby gem). Usage is as simple as

您可以使用pdf-reader(也可用作ruby gem)。用法很简单

reader = PDF::Reader.new("somefile.pdf")
puts reader.page_count

#1


19  

You can use pdf-reader (also available as a ruby gem). Usage is as simple as

您可以使用pdf-reader(也可用作ruby gem)。用法很简单

reader = PDF::Reader.new("somefile.pdf")
puts reader.page_count