Class: ActiveStorageValidations::Analyzer::PdfAnalyzer
- Inherits:
-
Analyzer
- Object
- Analyzer
- ActiveStorageValidations::Analyzer::PdfAnalyzer
- Defined in:
- lib/active_storage_validations/analyzer/pdf_analyzer.rb
Overview
ActiveStorageValidations PDF Analyzer
Extracts the following from a pdf attachable:
- Width (pts) => for the first page only
- Height (pts) => for the first page only
- Pages (integer) => number of pages in the pdf
Example:
ActiveStorageValidations::Analyzer::PdfAnalyzer.new(attachable).
# => { width: 150, height: 150, pages: 1 }
This analyzer requires the poppler system library, which is not provided by Rails.
Instance Method Summary collapse
Instance Method Details
#metadata ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/active_storage_validations/analyzer/pdf_analyzer.rb', line 21 def read_media do |media| { width: width, height: height, pages: pages }.compact end end |