class PDF::Writer::Object::Contents
The contents objects hold all of the content which appears on pages
Attributes
data[RW]
on_page[R]
Public Class Methods
new(parent, page = nil)
click to toggle source
Calls superclass method
PDF::Writer::Object::new
# File lib/pdf/writer/object/contents.rb 13 def initialize(parent, page = nil) 14 super(parent) 15 16 @data = RUBY_VERSION < '1.9' ? "" : "".force_encoding("UTF-8") 17 18 @info = {} 19 @raw = false 20 @on_page = nil 21 22 if page.kind_of?(PDF::Writer::Object::Page) 23 @on_page = page 24 elsif page == :raw 25 @raw = true 26 end 27 end
Public Instance Methods
<<(v)
click to toggle source
# File lib/pdf/writer/object/contents.rb 40 def <<(v) 41 raise TypeError unless v.kind_of?(PDF::Writer::Object) or v.kind_of?(String) 42 if RUBY_VERSION >= '1.9' 43 @data.force_encoding 'UTF-8' 44 v.force_encoding 'UTF-8' 45 end 46 @data << v 47 end
add(a)
click to toggle source
# File lib/pdf/writer/object/contents.rb 49 def add(a) 50 a.each { |k, v| @info[k] = v } 51 end
each() { |c| ... }
click to toggle source
# File lib/pdf/writer/object/contents.rb 36 def each 37 @contents.each { |c| yield c } 38 end
size()
click to toggle source
# File lib/pdf/writer/object/contents.rb 32 def size 33 @data.size 34 end
to_s()
click to toggle source
# File lib/pdf/writer/object/contents.rb 53 def to_s 54 tmp = @data.dup 55 res = "\n#{@oid} 0 obj\n" 56 if @raw 57 res << tmp 58 else 59 res << "<<" 60 if PDF::Writer::Compression and @parent.compressed? 61 res << " /Filter /FlateDecode" 62 tmp = Zlib::Deflate.deflate(tmp) 63 end 64 @info.each { |k, v| res << "\n/#{k} #{v}" } 65 res << "\n/Length #{tmp.size} >>\nstream\n#{tmp}\nendstream" 66 end 67 res << "\nendobj\n" 68 res 69 end