Class: ActiveStorageValidations::Analyzer::PdfAnalyzer

Inherits:
ActiveStorageValidations::Analyzer show all
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 Attribute Summary

Attributes inherited from ActiveStorageValidations::Analyzer

#attachable

Instance Method Summary collapse

Methods inherited from ActiveStorageValidations::Analyzer

#content_type, #initialize

Methods included from ActiveStorageValidations::ASVLoggable

#logger

Constructor Details

This class inherits a constructor from ActiveStorageValidations::Analyzer

Instance Method Details

#metadataObject



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