class Origami::Trailer

Class representing a PDF file Trailer.

Attributes

dictionary[R]
document[RW]
startxref[RW]

Public Class Methods

new(startxref = 0, dictionary = {}) click to toggle source

Creates a new Trailer.

startxref

The file offset to the XRef::Section.

dictionary

A hash of attributes to set in the Trailer Dictionary.

# File lib/origami/trailer.rb, line 113
def initialize(startxref = 0, dictionary = {})
    @startxref, self.dictionary = startxref, dictionary && Dictionary.new(dictionary)
end

Public Instance Methods

[](key) click to toggle source
# File lib/origami/trailer.rb, line 138
def [](key)
    @dictionary[key] if dictionary?
end
[]=(key,val) click to toggle source
# File lib/origami/trailer.rb, line 142
def []=(key,val)
    self.dictionary = Dictionary.new unless dictionary?
    @dictionary[key] = val
end
dictionary=(dict) click to toggle source
# File lib/origami/trailer.rb, line 147
def dictionary=(dict)
    dict.parent = self if dict
    @dictionary = dict
end
dictionary?() click to toggle source
# File lib/origami/trailer.rb, line 152
def dictionary?
    not @dictionary.nil?
end
to_obfuscated_str() click to toggle source
# File lib/origami/obfuscation.rb, line 233
def to_obfuscated_str
    content = ""
    if self.dictionary?
        content << TOKENS.first << EOL << @dictionary.to_obfuscated_str << EOL
    end

    content << XREF_TOKEN << EOL << @startxref.to_s << EOL << TOKENS.last << EOL

    content
end
to_s() click to toggle source

Outputs self into PDF code.

# File lib/origami/trailer.rb, line 159
def to_s
    content = ""
    if self.dictionary?
        content << TOKENS.first << EOL << @dictionary.to_s << EOL
    end

    content << XREF_TOKEN << EOL << @startxref.to_s << EOL << TOKENS.last << EOL

    content
end