13

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

Manish Shrivastava
  • 30,617
  • 13
  • 97
  • 101

1 Answers1

26

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

reader = PDF::Reader.new("somefile.pdf")
puts reader.page_count
jupp0r
  • 4,502
  • 1
  • 27
  • 34