简体   繁体   English

如何计算文件doc中的页面,docx在rails上使用ruby

[英]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.输入文件时,我无法计算 doc 和 docx 的页数。 Do you have any workarounds that can help me?您有任何可以帮助我的解决方法吗? Thank you谢谢

You can use yomu gem and get number of pages from metadata您可以使用yomu gem 并从元数据中获取页数

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM