Class: Podoff::Stream
- Inherits:
-
Object
- Object
- Podoff::Stream
- Defined in:
- lib/podoff.rb
Instance Attribute Summary collapse
-
#obj ⇒ Object
Returns the value of attribute obj.
Instance Method Summary collapse
- #bt(x, y, text) ⇒ Object (also: #text)
-
#initialize(obj = nil) ⇒ Stream
constructor
A new instance of Stream.
- #tf(font_name, font_size) ⇒ Object (also: #font)
- #to_s ⇒ Object
- #write(text) ⇒ Object
Constructor Details
#initialize(obj = nil) ⇒ Stream
Returns a new instance of Stream.
521 522 523 524 525 526 |
# File 'lib/podoff.rb', line 521 def initialize(obj=nil) @obj = obj @font = nil @content = StringIO.new end |
Instance Attribute Details
#obj ⇒ Object
Returns the value of attribute obj.
519 520 521 |
# File 'lib/podoff.rb', line 519 def obj @obj end |
Instance Method Details
#bt(x, y, text) ⇒ Object Also known as: text
536 537 538 539 540 541 542 543 |
# File 'lib/podoff.rb', line 536 def bt(x, y, text) @content.write "\n" if @content.size > 0 @content.write "BT " @content.write @font if @font @content.write "#{x} #{y} Td (#{escape(text)}) Tj" @content.write " ET" end |
#tf(font_name, font_size) ⇒ Object Also known as: font
528 529 530 531 532 533 |
# File 'lib/podoff.rb', line 528 def tf(font_name, font_size) n = font_name[0] == '/' ? font_name[1..-1] : font_name @font = "/#{n} #{font_size} Tf " end |
#to_s ⇒ Object
551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File 'lib/podoff.rb', line 551 def to_s s = @content.string f = '' if s.length > 98 f = ' /Filter /FlateDecode' s = Zlib::Deflate.deflate(s) end "#{obj.ref} obj\n" + "<</Length #{s.size}#{f}>>\nstream\n#{s}\nendstream\n" + "endobj" end |
#write(text) ⇒ Object
546 547 548 549 |
# File 'lib/podoff.rb', line 546 def write(text) @content.write(text) end |