Class: JotPDF::Core::ObjectWriteContext

Inherits:
WriteContext show all
Defined in:
lib/jot_pdf/core.rb

Instance Method Summary collapse

Methods inherited from WriteContext

#dsl, #initialize, #objects

Constructor Details

This class inherits a constructor from JotPDF::Core::WriteContext

Instance Method Details

#array(&block) ⇒ Object



130
131
132
133
134
# File 'lib/jot_pdf/core.rb', line 130

def array(&block)
  @writer << " ["
  ObjectWriteContext.new(@writer).dsl(&block)
  @writer << "]"
end

#bool(value) ⇒ Object



106
107
108
# File 'lib/jot_pdf/core.rb', line 106

def bool(value)
  @writer << " #{value}"
end

#content_stream(&block) ⇒ Object



151
152
153
154
155
# File 'lib/jot_pdf/core.rb', line 151

def content_stream(&block)
  stream do |w|
    ContentStreamWriteContext.new(w).dsl(&block)
  end
end

#dict(&block) ⇒ Object



136
137
138
139
140
# File 'lib/jot_pdf/core.rb', line 136

def dict(&block)
  @writer << " <<\n"
  DictionaryWriteContext.new(@writer).dsl(&block)
  @writer << ">>"
end

#hexstr(value) ⇒ Object



122
123
124
# File 'lib/jot_pdf/core.rb', line 122

def hexstr(value)
  @writer << " <" << value.to_s << ">"
end

#name(name) ⇒ Object



110
111
112
# File 'lib/jot_pdf/core.rb', line 110

def name(name)
  @writer << " /#{name}"
end

#nullObject



102
103
104
# File 'lib/jot_pdf/core.rb', line 102

def null
  @writer << " null"
end

#num(value) ⇒ Object



114
115
116
# File 'lib/jot_pdf/core.rb', line 114

def num(value)
  @writer << " " << value.to_s
end

#ref(object_ref) ⇒ Object



126
127
128
# File 'lib/jot_pdf/core.rb', line 126

def ref(object_ref)
  @writer << " #{object_ref.number} #{object_ref.generation} R"
end

#str(value) ⇒ Object



118
119
120
# File 'lib/jot_pdf/core.rb', line 118

def str(value)
  @writer << " (" << value.to_s << ")"
end

#stream {|@writer| ... } ⇒ Object

Yields:

  • (@writer)


142
143
144
145
146
147
148
149
# File 'lib/jot_pdf/core.rb', line 142

def stream
  @writer << "\nstream\n"
  stream_start = @writer.offset
  yield @writer
  stream_size = @writer.offset - stream_start
  @writer << "endstream"
  stream_size
end