Class: PDFGen::Document
- Inherits:
-
BaseRegion
- Object
- BaseRegion
- PDFGen::Document
- Includes:
- Canvas, CaptionContainer, Composite, DivContainer, ImageContainer, SpanContainer, TableContainer
- Defined in:
- lib/document.rb
Instance Attribute Summary collapse
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#pdf ⇒ Object
readonly
Returns the value of attribute pdf.
Attributes inherited from BaseRegion
Attributes included from BaseAttributes
#background_color, #border_bottom, #border_color, #border_left, #border_right, #border_style, #border_top, #border_width, #height, #is_breakable, #pad_bottom, #pad_left, #pad_right, #pad_top, #page_pad_top, #width
Instance Method Summary collapse
-
#break_page ⇒ Object
creates new page.
-
#initialize(pdf, page_pad_top) ⇒ Document
constructor
A new instance of Document.
- #render ⇒ Object
Methods included from Canvas
Methods included from Composite
#[], #add_region, #apply_values, #elements, #page_pad_top=, #regions, #render_regions
Methods included from TableContainer
Methods included from CaptionContainer
Methods included from SpanContainer
Methods included from DivContainer
Methods included from ImageContainer
Methods inherited from BaseRegion
#check_fit_in_height, #document, #minimal_height, #set_properties, #value
Methods included from BaseAttributes
#av_width, #border=, #border_params, #breakable?, included, #paddings=, #var_init
Methods included from BaseAttributes::ClassMethods
Constructor Details
#initialize(pdf, page_pad_top) ⇒ Document
Returns a new instance of Document.
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/document.rb', line 16 def initialize(pdf, page_pad_top) super(nil) pdf.y += pdf.top_margin # clear predefined top_margin pdf.y -= page_pad_top # set y considering page_pad_top pdf.top_margin = 0 @pdf = pdf @page_pad_top = page_pad_top @header = [] end |
Instance Attribute Details
#header ⇒ Object (readonly)
Returns the value of attribute header.
27 28 29 |
# File 'lib/document.rb', line 27 def header @header end |
#pdf ⇒ Object (readonly)
Returns the value of attribute pdf.
27 28 29 |
# File 'lib/document.rb', line 27 def pdf @pdf end |
Instance Method Details
#break_page ⇒ Object
creates new page
30 31 32 |
# File 'lib/document.rb', line 30 def break_page pdf.page_break @page_pad_top end |
#render ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/document.rb', line 34 def render pos = [0, pdf.y] regions.each do |region| pos[1] = pdf.y status = region.render(pos, pdf.y) if status[1] pdf.y -= status[0] else self.break_page redo end end end |