Class: Origami::Signature::DigitalSignature

Inherits:
Dictionary show all
Includes:
Origami::StandardObject
Defined in:
lib/origami/signature.rb

Overview

Class representing a digital signature.

Constant Summary

Constants included from Origami::StandardObject

Origami::StandardObject::DEFAULT_ATTRIBUTES

Constants inherited from Dictionary

Dictionary::TOKENS

Constants included from Object

Object::TOKENS

Instance Attribute Summary

Attributes inherited from Dictionary

#names_cache, #strings_cache, #xref_cache

Attributes included from Object

#file_offset, #generation, #no, #objstm_offset, #parent

Instance Method Summary collapse

Methods included from Origami::StandardObject

#do_type_check, #has_field?, included, #pdf_version_required, #set_default_value, #set_default_values

Methods inherited from Dictionary

#[], #[]=, #delete, #has_key?, #initialize, #map!, #merge, #method_missing, parse, #real_type, #to_obfuscated_str

Methods included from Object

#<=>, #copy, #indirect_parent, #initialize, #is_indirect?, parse, #pdf, #pdf_version_required, #post_build, #reference, #set_indirect, #set_pdf, #size, skip_until_next_obj, #solve, #to_o, #type, typeof, #xrefs

Methods inherited from Hash

#to_o

Constructor Details

This class inherits a constructor from Origami::Dictionary

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Origami::Dictionary

Instance Method Details

#pre_buildObject

:nodoc:



415
416
417
418
419
420
# File 'lib/origami/signature.rb', line 415

def pre_build #:nodoc:
  self.M = Origami::Date.now
  self.Prop_Build ||= BuildProperties.new.pre_build
  
  super
end

#sigOffsetObject

:nodoc:



438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/origami/signature.rb', line 438

def sigOffset #:nodoc:
  base = 1
  pairs = self.to_a
  content = "#{no} #{generation} obj" + EOL + TOKENS.first + EOL
  
  pairs.sort_by{ |k| k.to_s }.reverse.each do |pair|
    key, value = pair[0].to_o, pair[1].to_o
    
    if key == :Contents
      content << "\t" * base + key.to_s + " "
      
      return content.size
    else
      content << "\t" * base + key.to_s + " " + (value.is_a?(Dictionary) ? value.to_s(base+1) : value.to_s) + EOL
    end
  end
    
  nil
end

#to_s(dummy_param = nil) ⇒ Object

:nodoc:



422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/origami/signature.rb', line 422

def to_s(dummy_param = nil) #:nodoc:
  indent = 1
  pairs = self.to_a
  content = TOKENS.first + EOL
  
  pairs.sort_by{ |k| k.to_s }.reverse.each do |pair|
    key, value = pair[0].to_o, pair[1].to_o
      
    content << "\t" * indent + key.to_s + " " + (value.is_a?(Dictionary) ? value.to_s(indent + 1) : value.to_s) + EOL
  end
  
  content << "\t" * (indent - 1) + TOKENS.last
  
  output(content)
end