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

#[], #[]=, add_type_info, #cast_to, #copy, #delete, guess_type, #has_key?, hint_type, #initialize, #map!, #merge, #method_missing, native_type, parse, #to_obfuscated_str

Methods included from Object

#<=>, #cast_to, #copy, #export, #indirect_parent, #initialize, #is_indirect?, #logicalize, #logicalize!, #native_type, native_type, parse, #pdf, #pdf_version_required, #post_build, #reference, #resolve_all_references, #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:



433
434
435
436
437
438
# File 'lib/origami/signature.rb', line 433

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

#sigOffsetObject

:nodoc:



456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/origami/signature.rb', line 456

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:



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

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