Class: RPDF::PDFStream

Inherits:
PDFObject show all
Defined in:
lib/rpdf/pdfstream.rb

Overview

Stream Object TODO: stream dictionary

PDFRef15 p36

Instance Attribute Summary collapse

Attributes inherited from PDFObject

#generation_number, #object_number

Instance Method Summary collapse

Methods inherited from PDFObject

#indirect?, #invalidated?, #to_pdf, #to_ref

Constructor Details

#initialize(data, document = nil) ⇒ PDFStream

Returns a new instance of PDFStream.



12
13
14
15
16
# File 'lib/rpdf/pdfstream.rb', line 12

def initialize(data, document=nil)
  @data = data
  @dict = PDFDictionary.new({ :Length => data.size })
  super(document)
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/rpdf/pdfstream.rb', line 10

def data
  @data
end

#dictObject (readonly)

Returns the value of attribute dict.



10
11
12
# File 'lib/rpdf/pdfstream.rb', line 10

def dict
  @dict
end

Instance Method Details

#invalidateObject



18
19
20
21
# File 'lib/rpdf/pdfstream.rb', line 18

def invalidate
  super
  @data = nil
end

#to_sObject



23
24
25
26
27
28
# File 'lib/rpdf/pdfstream.rb', line 23

def to_s
  bytes = @dict.to_pdf
  bytes << "stream\n"
  bytes << data
  bytes << "\nendstream"
end