Class: Prawn::Core::Page
- Inherits:
-
Object
- Object
- Prawn::Core::Page
- Defined in:
- lib/prawn/core/page.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#dictionary ⇒ Object
Returns the value of attribute dictionary.
-
#document ⇒ Object
Returns the value of attribute document.
-
#layout ⇒ Object
Returns the value of attribute layout.
-
#margins ⇒ Object
Returns the value of attribute margins.
-
#size ⇒ Object
Returns the value of attribute size.
Instance Method Summary collapse
- #dimensions ⇒ Object
- #ext_gstates ⇒ Object
- #fonts ⇒ Object
- #in_stamp_stream? ⇒ Boolean
-
#initialize(document, options = {}) ⇒ Page
constructor
A new instance of Page.
- #resources ⇒ Object
- #stamp_stream(dictionary) ⇒ Object
- #xobjects ⇒ Object
Constructor Details
#initialize(document, options = {}) ⇒ Page
Returns a new instance of Page.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/prawn/core/page.rb', line 12 def initialize(document, ={}) @document = document @size = [:size] || "LETTER" @layout = [:layout] || :portrait @margins = [:margins] || { :left => 36, :right => 36, :top => 36, :bottom => 36 } @content = document.ref(:Length => 0) @dictionary = document.ref(:Type => :Page, :Parent => document.store.pages, :MediaBox => dimensions, :Contents => content) resources[:ProcSet] = [:PDF, :Text, :ImageB, :ImageC, :ImageI] @stamp_stream = nil @stamp_dictionary = nil end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
35 36 37 |
# File 'lib/prawn/core/page.rb', line 35 def content @content end |
#dictionary ⇒ Object
Returns the value of attribute dictionary.
35 36 37 |
# File 'lib/prawn/core/page.rb', line 35 def dictionary @dictionary end |
#document ⇒ Object
Returns the value of attribute document.
35 36 37 |
# File 'lib/prawn/core/page.rb', line 35 def document @document end |
#layout ⇒ Object
Returns the value of attribute layout.
35 36 37 |
# File 'lib/prawn/core/page.rb', line 35 def layout @layout end |
#margins ⇒ Object
Returns the value of attribute margins.
35 36 37 |
# File 'lib/prawn/core/page.rb', line 35 def margins @margins end |
#size ⇒ Object
Returns the value of attribute size.
35 36 37 |
# File 'lib/prawn/core/page.rb', line 35 def size @size end |
Instance Method Details
#dimensions ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/prawn/core/page.rb', line 56 def dimensions coords = Prawn::Document::PageGeometry::SIZES[size] || size [0,0] + case(layout) when :portrait coords when :landscape coords.reverse else raise Prawn::Errors::InvalidPageLayout, "Layout must be either :portrait or :landscape" end end |
#ext_gstates ⇒ Object
89 90 91 |
# File 'lib/prawn/core/page.rb', line 89 def ext_gstates resources[:ExtGState] ||= {} end |
#fonts ⇒ Object
81 82 83 |
# File 'lib/prawn/core/page.rb', line 81 def fonts resources[:Font] ||= {} end |
#in_stamp_stream? ⇒ Boolean
37 38 39 |
# File 'lib/prawn/core/page.rb', line 37 def in_stamp_stream? !!@stamp_stream end |
#resources ⇒ Object
77 78 79 |
# File 'lib/prawn/core/page.rb', line 77 def resources dictionary.data[:Resources] ||= {} end |
#stamp_stream(dictionary) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/prawn/core/page.rb', line 41 def stamp_stream(dictionary) @stamp_stream = "" @stamp_dictionary = dictionary document.send(:update_colors) yield if block_given? document.send(:update_colors) @stamp_dictionary.data[:Length] = @stamp_stream.length + 1 @stamp_dictionary << @stamp_stream @stamp_stream = nil @stamp_dictionary = nil end |
#xobjects ⇒ Object
85 86 87 |
# File 'lib/prawn/core/page.rb', line 85 def xobjects resources[:XObject] ||= {} end |