Phạm Minh Phương
Phạm Minh Phương

Reputation: 31

How to count page in file doc, docx use ruby on rails

I am having trouble counting the number of pages doc and docx when inputting a file. Do you have any workarounds that can help me? Thank you

Upvotes: 1

Views: 224

Answers (1)

Touqeer
Touqeer

Reputation: 658

You can use yomu gem and get number of pages from metadata

doc_data = File.read 'sample_file.docx'
metadata = Yomu.read :metadata, doc_data
page_numbers = metadata['Page-Count']

Upvotes: 2

Related Questions