如何使用 Ruby 计算 Microsoft Word 文件的页数?
在 Ruby Web 应用程序中,我希望用户能够上传文档。 如果用户上传 Microsoft Word 文件 (.doc),我希望 Ruby 计算文件中的页数。 获取字数会更灵活,但获取页数就可以了。
我该怎么做呢? 有没有 Ruby 库/gem 可以帮我做到这一点? 考虑到 DOC 格式,这是否可能?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对文档的 Range 对象调用 ComputeStatistics() 方法:
您将找到各种有关使用 Ruby 自动化 Word 的文章 此处。
Call the ComputeStatistics() method on the document's Range object:
You'll find various articles on automating Word with Ruby here.
在 ruby 中,要打开 Word 文件,您需要使用:(
来源:http:// www.ruby-forum.com/topic/99742#214485)
请参阅:http:// /www.perlmonks.org/?node_id=614609 获取正确/预期字数的算法(注意:该算法是用 perl 编写的)
然后:
In ruby, to open a word file you need to use:
(source: http://www.ruby-forum.com/topic/99742#214485)
See: http://www.perlmonks.org/?node_id=614609 for an algorithm on getting the proper/expected word count (note: the algo is in perl)
Then: