gdelugre / origami

Origami is a pure Ruby library to parse, modify and generate PDF documents.
GNU Lesser General Public License v3.0
326 stars 110 forks source link

Pages counter pdf #53

Closed curiosport closed 5 years ago

curiosport commented 5 years ago

Hello.

What part of your code counts pages in a pdf? I would like to be able to use that code without having to import the gem into my module.

Thank you.

gdelugre commented 5 years ago

The core method counting the pages is PageTreeNode#each_page. It returns a page Enumerator whose #size method will return the number of pages. It has to be used on the root tree node to get the total number of pages in the document.

However the code is totally dependent on the rest of the framework, so it's not like you will be able to extract it and run it separately.