Class: ODDB::FiPDF::Format
- Defined in:
- ext/fipdf/src/format.rb,
ext/fipdf/test/format_test.rb
Constant Summary collapse
- WRITER_CLASS =
PDF::Writer
Instance Attribute Summary collapse
-
#differences ⇒ Object
Returns the value of attribute differences.
-
#font ⇒ Object
Returns the value of attribute font.
-
#fontsize ⇒ Object
Returns the value of attribute fontsize.
-
#justification ⇒ Object
Returns the value of attribute justification.
-
#margin ⇒ Object
Returns the value of attribute margin.
-
#size ⇒ Object
Returns the value of attribute size.
- #spacing_after(text) ⇒ Object
-
#spacing_before(text) ⇒ Object
Returns the value of attribute spacing_before.
-
#writer ⇒ Object
Returns the value of attribute writer.
-
#ypos ⇒ Object
Returns the value of attribute ypos.
Instance Method Summary collapse
- #font_height(font) ⇒ Object
- #get_height(text, width) ⇒ Object
-
#initialize ⇒ Format
constructor
A new instance of Format.
- #line_count(text, width) ⇒ Object
Constructor Details
#initialize ⇒ Format
Returns a new instance of Format.
14 15 16 17 18 |
# File 'ext/fipdf/src/format.rb', line 14 def initialize @writer = WRITER_CLASS.new @spacing_before = 0 @spacing_after = 0 end |
Instance Attribute Details
#differences ⇒ Object
Returns the value of attribute differences.
9 10 11 |
# File 'ext/fipdf/src/format.rb', line 9 def differences @differences end |
#font ⇒ Object
Returns the value of attribute font.
9 10 11 |
# File 'ext/fipdf/src/format.rb', line 9 def font @font end |
#fontsize ⇒ Object
Returns the value of attribute fontsize.
9 10 11 |
# File 'ext/fipdf/src/format.rb', line 9 def fontsize @fontsize end |
#justification ⇒ Object
Returns the value of attribute justification.
9 10 11 |
# File 'ext/fipdf/src/format.rb', line 9 def justification @justification end |
#margin ⇒ Object
Returns the value of attribute margin.
9 10 11 |
# File 'ext/fipdf/src/format.rb', line 9 def margin @margin end |
#size ⇒ Object
Returns the value of attribute size.
9 10 11 |
# File 'ext/fipdf/src/format.rb', line 9 def size @size end |
#spacing_after(text) ⇒ Object
43 44 45 |
# File 'ext/fipdf/src/format.rb', line 43 def spacing_after(text) (text.to_s.strip.empty?) ? 0 : @spacing_after end |
#spacing_before(text) ⇒ Object
Returns the value of attribute spacing_before.
9 10 11 |
# File 'ext/fipdf/src/format.rb', line 9 def spacing_before @spacing_before end |
#writer ⇒ Object
Returns the value of attribute writer.
12 13 14 |
# File 'ext/fipdf/src/format.rb', line 12 def writer @writer end |
#ypos ⇒ Object
Returns the value of attribute ypos.
9 10 11 |
# File 'ext/fipdf/src/format.rb', line 9 def ypos @ypos end |
Instance Method Details
#font_height(font) ⇒ Object
40 41 42 |
# File 'ext/fipdf/src/format.rb', line 40 def font_height(font) @writer.font_height(font) end |
#get_height(text, width) ⇒ Object
35 36 37 38 39 |
# File 'ext/fipdf/src/format.rb', line 35 def get_height(text, width) line_count(text, width) \ * @writer.font_height(@size) \ - spacing_before(text) - spacing_after(text) end |
#line_count(text, width) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'ext/fipdf/src/format.rb', line 19 def line_count(text, width) return 0 if text.to_s.empty? @writer.select_font(@font, { :differences => @differences }) text = text.dup line_count = 0 text.each_line { |line| begin line_count += 1 line = @writer.add_text_wrap(0, 0, width,\ line, @size, @justification, 0, true) end while(!line.empty?) } line_count end |