Class: DocXify::Element::PageLayout
- Defined in:
- lib/docxify/element/page_layout.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
Returns the value of attribute height.
-
#orientation ⇒ Object
Returns the value of attribute orientation.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
- #bounds_height ⇒ Object
-
#bounds_width ⇒ Object
Don’t consider this part of the public API, they’re used by Document if it’s been created.
-
#initialize(options = {}) ⇒ PageLayout
constructor
A new instance of PageLayout.
- #to_s(_container = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ PageLayout
Returns a new instance of PageLayout.
9 10 11 12 13 14 15 16 |
# File 'lib/docxify/element/page_layout.rb', line 9 def initialize( = {}) super() @document = [:document] @margins = @document.margins @width = [:width] || @document&.width || DocXify::A4_PORTRAIT_WIDTH @height = [:height] || @document&.height || DocXify::A4_PORTRAIT_HEIGHT @orientation = [:orientation] || :portrait end |
Instance Attribute Details
#height ⇒ Object
Returns the value of attribute height.
7 8 9 |
# File 'lib/docxify/element/page_layout.rb', line 7 def height @height end |
#orientation ⇒ Object
Returns the value of attribute orientation.
7 8 9 |
# File 'lib/docxify/element/page_layout.rb', line 7 def orientation @orientation end |
#width ⇒ Object
Returns the value of attribute width.
7 8 9 |
# File 'lib/docxify/element/page_layout.rb', line 7 def width @width end |
Instance Method Details
#bounds_height ⇒ Object
23 24 25 |
# File 'lib/docxify/element/page_layout.rb', line 23 def bounds_height @height - @margins[:top] - @margins[:bottom] end |
#bounds_width ⇒ Object
Don’t consider this part of the public API, they’re used by Document if it’s been created
19 20 21 |
# File 'lib/docxify/element/page_layout.rb', line 19 def bounds_width @width - @margins[:left] - @margins[:right] end |
#to_s(_container = nil) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/docxify/element/page_layout.rb', line 27 def to_s(_container = nil) <<~XML <w:p> <w:pPr> <w:sectPr> <w:pgSz w:w="#{@width}" w:h="#{@height}" w:orient="#{@orientation}"/> <w:pgMar w:bottom="#{DocXify.cm2dxa @margins[:bottom]}" w:footer="708" w:gutter="0" w:header="708" w:left="#{DocXify.cm2dxa @margins[:left]}" w:right="#{DocXify.cm2dxa @margins[:right]}" w:top="#{DocXify.cm2dxa @margins[:top]}"/> <w:cols w:space="708"/> <w:docGrid w:linePitch="360"/> </w:sectPr> </w:pPr> </w:p> XML end |