class Origami::Page

Class representing a Page in the PDF document.

Constants

Activation
Animation
Asset
Assets
Binding
C
Condition
Configuration
Configurations
Contents
Deactivation
FlashVars
Instances
NA
Names
O
PA
Params
PassContextClick
Presentation
Resources
RichMediaContent
RichMediaSettings
Style
Subtype
Toolbar
Transparent

Public Class Methods

new(hash = {}, parser = nil) click to toggle source
Calls superclass method Origami::Dictionary::new
# File lib/origami/page.rb, line 570
def initialize(hash = {}, parser = nil)
    super(hash, parser)

    set_indirect(true)
end

Public Instance Methods

add_annotation(*annotations) click to toggle source

Add an Annotation to the Page.

# File lib/origami/page.rb, line 613
def add_annotation(*annotations)
    unless annotations.all?{|annot| annot.is_a?(Annotation) or annot.is_a?(Reference)}
        raise TypeError, "Only Annotation objects must be passed."
    end

    self.Annots ||= []

    annotations.each do |annot|
        annot.solve[:P] = self if self.indirect?
        self.Annots << annot
    end
end
add_flash_application(swfspec, params = {}) click to toggle source

Embed a SWF Flash application in the page.

# File lib/origami/page.rb, line 650
def add_flash_application(swfspec, params = {})
    options =
    {
        windowed: false,
        transparent: false,
        navigation_pane: false,
        toolbar: false,
        pass_context_click: false,
        activation: Annotation::RichMedia::Activation::PAGE_OPEN,
        deactivation: Annotation::RichMedia::Deactivation::PAGE_CLOSE,
        flash_vars: nil
    }
    options.update(params)

    annot = create_richmedia(:Flash, swfspec, options)
    add_annotation(annot)

    annot
end
annotations() click to toggle source

Returns the array of Annotation objects of the Page.

# File lib/origami/page.rb, line 643
def annotations
    self.each_annotation.to_a
end
content_streams() click to toggle source

Returns an Array of ContentStreams for the Page.

# File lib/origami/page.rb, line 606
def content_streams
    self.each_content_stream.to_a
end
draw_image() click to toggle source

TODO :nodoc:

# File lib/origami/graphics/xobject.rb, line 464
def draw_image
    raise NotImplementedError
end
draw_line(from, to, attr = {}) click to toggle source

See ContentStream#draw_line.

# File lib/origami/graphics/xobject.rb, line 469
def draw_line(from, to, attr = {})
    last_content_stream.draw_line(from, to, attr); self
end
draw_polygon(coords = [], attr = {}) click to toggle source

See ContentStream#draw_polygon.

# File lib/origami/graphics/xobject.rb, line 474
def draw_polygon(coords = [], attr = {})
    last_content_stream.draw_polygon(coords, attr); self
end
draw_rectangle(x, y, width, height, attr = {}) click to toggle source

See ContentStream#draw_rectangle.

# File lib/origami/graphics/xobject.rb, line 479
def draw_rectangle(x, y, width, height, attr = {})
    last_content_stream.draw_rectangle(x, y, width, height, attr); self
end
each_annotation() { |solve| ... } click to toggle source

Iterate through each Annotation of the Page.

# File lib/origami/page.rb, line 629
def each_annotation
    annots = self.Annots

    return enum_for(__method__) { annots.is_a?(Array) ? annots.length : 0 } unless block_given?
    return unless annots.is_a?(Array)

    annots.each do |annot|
        yield(annot.solve)
    end
end
each_content_stream() { |contents| ... } click to toggle source

Iterates over all the ContentStreams of the Page.

# File lib/origami/page.rb, line 585
def each_content_stream
    contents = self.Contents

    return enum_for(__method__) do
        case contents
        when Array then contents.length
        when Stream then 1
        else
            0
        end
    end unless block_given?

    case contents
    when Stream then yield(contents)
    when Array then contents.each { |stm| yield(stm.solve) }
    end
end
onClose(action) click to toggle source

Will execute an action when the page is closed.

# File lib/origami/page.rb, line 687
def onClose(action)
    unless action.is_a?(Action) or action.is_a?(Reference)
        raise TypeError, "An Action object must be passed."
    end

    self.AA ||= Page::AdditionalActions.new
    self.AA.C = action

    self
end
onOpen(action) click to toggle source

Will execute an action when the page is opened.

# File lib/origami/page.rb, line 673
def onOpen(action)
    unless action.is_a?(Action) or action.is_a?(Reference)
        raise TypeError, "An Action object must be passed."
    end

    self.AA ||= Page::AdditionalActions.new
    self.AA.O = action

    self
end
paint_shading(shade) click to toggle source

TODO :nodoc:

# File lib/origami/graphics/xobject.rb, line 489
def paint_shading(shade)
    last_content_stream.paint_shading(shade)
end
pre_build() click to toggle source
Calls superclass method Origami::Object#pre_build
# File lib/origami/page.rb, line 576
def pre_build
    self.Resources = Resources.new.pre_build unless self.has_key?(:Resources)

    super
end
set_dash_pattern(pattern) click to toggle source

See ContentStream#set_dash_pattern.

# File lib/origami/graphics/xobject.rb, line 544
def set_dash_pattern(pattern)
    last_content_stream.set_dash_pattern(pattern); self
end
set_fill_color(color) click to toggle source

See ContentStream#set_fill_color.

# File lib/origami/graphics/xobject.rb, line 534
def set_fill_color(color)
    last_content_stream.set_fill_color(color); self
end
set_line_cap(cap) click to toggle source

See ContentStream#set_line_cap.

# File lib/origami/graphics/xobject.rb, line 554
def set_line_cap(cap)
    last_content_stream.set_line_cap(cap); self
end
set_line_join(join) click to toggle source

See ContentStream#set_line_join.

# File lib/origami/graphics/xobject.rb, line 559
def set_line_join(join)
    last_content_stream.set_line_join(join); self
end
set_line_width(width) click to toggle source

See ContentStream#set_line_width.

# File lib/origami/graphics/xobject.rb, line 549
def set_line_width(width)
    last_content_stream.set_line_width(width); self
end
set_stroke_color(color) click to toggle source

See ContentStream#set_stroke_color.

# File lib/origami/graphics/xobject.rb, line 539
def set_stroke_color(color)
    last_content_stream.set_stroke_color(color); self
end
set_text_char_spacing(char_spacing) click to toggle source

See ContentStream#set_text_char_spacing.

# File lib/origami/graphics/xobject.rb, line 529
def set_text_char_spacing(char_spacing)
    last_content_stream.set_text_char_spacing(char_spacing); self
end
set_text_font(_font, _size) click to toggle source

TODO :nodoc:

# File lib/origami/graphics/xobject.rb, line 494
def set_text_font(_font, _size)
    raise NotImplementedError
end
set_text_leading(leading) click to toggle source

See ContentStream#set_text_leading.

# File lib/origami/graphics/xobject.rb, line 504
def set_text_leading(leading)
    last_content_stream.set_text_leading(leading); self
end
set_text_pos(tx, ty) click to toggle source

See ContentStream#set_text_pos.

# File lib/origami/graphics/xobject.rb, line 499
def set_text_pos(tx, ty)
    last_content_stream.set_text_pos(tx, ty); self
end
set_text_rendering(rendering) click to toggle source

See ContentStream#set_text_rendering.

# File lib/origami/graphics/xobject.rb, line 509
def set_text_rendering(rendering)
    last_content_stream.set_text_rendering(rendering); self
end
set_text_rise(rise) click to toggle source

See ContentStream#set_text_rise.

# File lib/origami/graphics/xobject.rb, line 514
def set_text_rise(rise)
    last_content_stream.set_text_rise(rise); self
end
set_text_scale(scaling) click to toggle source

See ContentStream#set_text_scale.

# File lib/origami/graphics/xobject.rb, line 519
def set_text_scale(scaling)
    last_content_stream.set_text_scale(scaling); self
end
set_text_word_spacing(word_spacing) click to toggle source

See ContentStream#set_text_word_spacing.

# File lib/origami/graphics/xobject.rb, line 524
def set_text_word_spacing(word_spacing)
    last_content_stream.set_text_word_spacing(word_spacing); self
end
write(text, attr = {}) click to toggle source

See ContentStream#write.

# File lib/origami/graphics/xobject.rb, line 484
def write(text, attr = {})
    last_content_stream.write(text, attr); self
end