| Class | PDF::Writer::Object::Contents |
| In: |
lib/pdf/writer/object/contents.rb
|
| Parent: | PDF::Writer::Object |
The contents objects hold all of the content which appears on pages
| data | [RW] | |
| on_page | [R] |
# File lib/pdf/writer/object/contents.rb, line 13
13: def initialize(parent, page = nil)
14: super(parent)
15:
16: @data = ""
17: @info = {}
18: @raw = false
19: @on_page = nil
20:
21: if page.kind_of?(PDF::Writer::Object::Page)
22: @on_page = page
23: elsif page == :raw
24: @raw = true
25: end
26: end
# File lib/pdf/writer/object/contents.rb, line 39
39: def <<(v)
40: raise TypeError unless v.kind_of?(PDF::Writer::Object) or v.kind_of?(String)
41: @data << v
42: end
# File lib/pdf/writer/object/contents.rb, line 44
44: def add(a)
45: a.each { |k, v| @info[k] = v }
46: end
# File lib/pdf/writer/object/contents.rb, line 35
35: def each
36: @contents.each { |c| yield c }
37: end
# File lib/pdf/writer/object/contents.rb, line 48
48: def to_s
49: tmp = @data.dup
50: res = "\n#{@oid} 0 obj\n"
51: if @raw
52: res << tmp
53: else
54: res << "<<"
55: if PDF::Writer::Compression and @parent.compressed?
56: res << " /Filter /FlateDecode"
57: tmp = Zlib::Deflate.deflate(tmp)
58: end
59: @info.each { |k, v| res << "\n/#{k} #{v}" }
60: res << "\n/Length #{tmp.size} >>\nstream\n#{tmp}\nendstream"
61: end
62: res << "\nendobj\n"
63: res
64: end