Class: Prune::Elements::Page
Constant Summary collapse
- FONT_OPTIONS =
[ :name, # Font name. :size, # Font size. :bold, # Bold(boolean). :italic, # Italic(boolean). :mode, # Font color mode. :fill_color, # Color inside font. :stroke_color, # Color around font. ]
Instance Attribute Summary collapse
-
#current_font ⇒ Object
Returns the value of attribute current_font.
-
#default_font ⇒ Object
readonly
Returns the value of attribute default_font.
-
#margin_bottom ⇒ Object
Returns the value of attribute margin_bottom.
-
#margin_left ⇒ Object
Returns the value of attribute margin_left.
-
#margin_right ⇒ Object
Returns the value of attribute margin_right.
-
#margin_top ⇒ Object
Returns the value of attribute margin_top.
-
#shape_ids ⇒ Object
Returns the value of attribute shape_ids.
-
#shapes ⇒ Object
Returns the value of attribute shapes.
-
#x ⇒ Object
Returns the value of attribute x.
-
#y ⇒ Object
Returns the value of attribute y.
Attributes inherited from Base
Instance Method Summary collapse
-
#height ⇒ Object
Get height of the page(pt).
-
#initialize(document, media_box, options = {}) ⇒ Page
constructor
Initialize.
-
#set_font(key, font) ⇒ Object
Set font to use.
-
#stream ⇒ Object
Get stream object.
-
#width ⇒ Object
Get width of the page(pt).
Methods inherited from Base
Methods included from Functions
Methods included from PObjects
Constructor Details
#initialize(document, media_box, options = {}) ⇒ Page
Initialize.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/prune/elements/page.rb', line 28 def initialize(document, media_box, = {}) super(document) # Set stream. @stream = Stream.new(@document) # Set dictionary. @media_box = media_box @content = pd( pn(:Type) => pn(:Page), pn(:Parent) => @document.pages.reference, pn(:MediaBox) => pa(*@media_box), pn(:Contents) => @stream.reference, pn(:Resources) => pd( pn(:ProcSet) => @document.proc_set.reference)) # Set page margin by option in millimeters(default 10mm). %w[top left right bottom].each do |position| value = ["margin_#{position}".to_sym] || 10.0 value = mm_to_pt(value) instance_variable_set("@margin_#{position}", value) end # Set initial position. @x = @margin_left @y = @media_box[3] - @margin_top # Set page default font. initialize_font() # Initialize page shapes. @shape_ids = [] @shapes = {} # Register element to document. register end |
Instance Attribute Details
#current_font ⇒ Object
Returns the value of attribute current_font.
11 12 13 |
# File 'lib/prune/elements/page.rb', line 11 def current_font @current_font end |
#default_font ⇒ Object (readonly)
Returns the value of attribute default_font.
6 7 8 |
# File 'lib/prune/elements/page.rb', line 6 def default_font @default_font end |
#margin_bottom ⇒ Object
Returns the value of attribute margin_bottom.
15 16 17 |
# File 'lib/prune/elements/page.rb', line 15 def margin_bottom @margin_bottom end |
#margin_left ⇒ Object
Returns the value of attribute margin_left.
12 13 14 |
# File 'lib/prune/elements/page.rb', line 12 def margin_left @margin_left end |
#margin_right ⇒ Object
Returns the value of attribute margin_right.
13 14 15 |
# File 'lib/prune/elements/page.rb', line 13 def margin_right @margin_right end |
#margin_top ⇒ Object
Returns the value of attribute margin_top.
14 15 16 |
# File 'lib/prune/elements/page.rb', line 14 def margin_top @margin_top end |
#shape_ids ⇒ Object
Returns the value of attribute shape_ids.
7 8 9 |
# File 'lib/prune/elements/page.rb', line 7 def shape_ids @shape_ids end |
#shapes ⇒ Object
Returns the value of attribute shapes.
8 9 10 |
# File 'lib/prune/elements/page.rb', line 8 def shapes @shapes end |
#x ⇒ Object
Returns the value of attribute x.
9 10 11 |
# File 'lib/prune/elements/page.rb', line 9 def x @x end |
#y ⇒ Object
Returns the value of attribute y.
10 11 12 |
# File 'lib/prune/elements/page.rb', line 10 def y @y end |
Instance Method Details
#height ⇒ Object
Get height of the page(pt).
74 75 76 |
# File 'lib/prune/elements/page.rb', line 74 def height @media_box[3] - @margin_top - @margin_bottom end |
#set_font(key, font) ⇒ Object
Set font to use.
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/prune/elements/page.rb', line 79 def set_font(key, font) # Add :Font key to content hash unless there is no key unless @content[pn(:Resources)].has_key?(pn(:Font)) @content[pn(:Resources)].update(pn(:Font) => pd) end # Add font symbol to :Font hash unless @content[pn(:Resources)][pn(:Font)].has_key?(key) @content[pn(:Resources)][pn(:Font)].update(key => font.reference) end end |
#stream ⇒ Object
Get stream object.
64 65 66 |
# File 'lib/prune/elements/page.rb', line 64 def stream @stream.stream end |
#width ⇒ Object
Get width of the page(pt).
69 70 71 |
# File 'lib/prune/elements/page.rb', line 69 def width @media_box[2] - @margin_left - @margin_right end |