I need to count the number of pages in a docs file, There are many pages in a docs file, I want to count the number of pages in it to facilitate input Currently I only count the number of pages if it is a pdf file
Do you know any technology or gem that can solve it?
Thanks so much
I believe you can use the docsplit
gem. You can find the documentation here .
Gemfile:
gem docsplit
Then you should be able to retrieve the number of pages with:
Docsplit.extract_length('path/to/stooges.docx')
Or you could convert your document to PDF and return the number of pages with the method you already know. Using docsplit-paperclip-processor
, find the documentation enter link description here .
Gemfile:
gem 'docsplit-paperclip-processor'
Then run bundle install
. Then in your model:
class Document < ActiveRecord::Base
has_attached_file :file,
:styles => {
:pdf => {
:format => "pdf",
:processors => [:docsplit_pdf]
}
}
end
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.