Class: DPTM6::PDF::StreamObject

Inherits:
Object
  • Object
show all
Defined in:
lib/dptm6/pdf.rb

Instance Attribute Summary collapse

Attributes inherited from Object

#data, #num, #pdf

Instance Method Summary collapse

Methods inherited from Object

#initialize, #move_to, #replace_pagenum

Constructor Details

This class inherits a constructor from DPTM6::PDF::Object

Instance Attribute Details

#obj_lengthObject (readonly)

Returns the value of attribute obj_length.



232
233
234
# File 'lib/dptm6/pdf.rb', line 232

def obj_length
  @obj_length
end

Instance Method Details

#set_deflevel(level) ⇒ Object



234
235
236
# File 'lib/dptm6/pdf.rb', line 234

def set_deflevel(level)
  @def_level = level if @stream
end

#streamObject



238
239
240
# File 'lib/dptm6/pdf.rb', line 238

def stream
  Zlib.inflate(@stream)
end

#stream=(str) ⇒ Object



242
243
244
# File 'lib/dptm6/pdf.rb', line 242

def stream=(str)
  @stream = Zlib.deflate(str, @def_level)
end

#to_stringObject



246
247
248
249
250
251
252
253
254
255
256
# File 'lib/dptm6/pdf.rb', line 246

def to_string
  replace_pagenum('/Length' => @obj_length.num)

  buf = "#{@num} #{0} obj\n"
  buf << @data
  if @stream
    @obj_length.data = "   #{@stream.length}\n"
    buf << "stream\n" << @stream << "\nendstream\n"
  end
  buf << "endobj\n"
end

#writeObject



258
259
260
261
# File 'lib/dptm6/pdf.rb', line 258

def write
  super
  @obj_length.write
end