Class: PDFUtilities::PDFValidator::Validator

Inherits:
Object
  • Object
show all
Defined in:
lib/pdf_utilities/pdf_validator.rb

Constant Summary collapse

DEFAULT_OPTIONS =
{
  size_limit_in_bytes: 100_000_000, # 100 MB
  check_page_dimensions: true,
  check_encryption: true,
  # Height/width limits are ignored if the check_page_dimensions option is false.
  width_limit_in_inches: 21,
  height_limit_in_inches: 21
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file, options = {}) ⇒ Validator

‘file’ can be a File, Tempfile, or a String file path



58
59
60
61
# File 'lib/pdf_utilities/pdf_validator.rb', line 58

def initialize(file, options = {})
  @file = file
  @options = DEFAULT_OPTIONS.merge(options)
end

Instance Attribute Details

#pdf_metadataObject

Returns the value of attribute pdf_metadata.



55
56
57
# File 'lib/pdf_utilities/pdf_validator.rb', line 55

def 
  @pdf_metadata
end

#resultObject

Returns the value of attribute result.



55
56
57
# File 'lib/pdf_utilities/pdf_validator.rb', line 55

def result
  @result
end

Instance Method Details

#validateObject



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/pdf_utilities/pdf_validator.rb', line 63

def validate
  @result = ValidationResult.new
  @pdf_metadata = nil

  check_file_size
  
  check_encryption if @options[:check_encryption]
  check_page_size if @options[:check_page_dimensions]

  @result
end