Class: Origami::XRefStream
- Includes:
- Enumerable, StandardObject
- Defined in:
- lib/origami/xreftable.rb
Overview
Class representing a XRef Stream.
Constant Summary collapse
- XREF_FREE =
0
- XREF_USED =
1
- XREF_COMPRESSED =
2
Constants included from StandardObject
StandardObject::DEFAULT_ATTRIBUTES
Constants inherited from Stream
Constants included from Object
Instance Attribute Summary
Attributes inherited from Stream
Attributes included from Object
#file_offset, #generation, #no, #objstm_offset, #parent
Instance Method Summary collapse
-
#<<(xref) ⇒ Object
Adds an XRef to this Stream.
- #clear ⇒ Object
-
#each(&b) ⇒ Object
Iterates over each XRef present in the stream.
- #entries ⇒ Object
-
#find(no) ⇒ Object
Returns an XRef matching this object number.
-
#initialize(data = "", dictionary = {}) ⇒ XRefStream
constructor
A new instance of XRefStream.
-
#pre_build ⇒ Object
Returns XRef entries present in this stream.
Methods included from StandardObject
#do_type_check, #has_field?, included, #pdf_version_required, #set_default_value, #set_default_values
Methods inherited from Stream
#[], #[]=, #data, #data=, #decode!, #each_key, #encode!, #method_missing, parse, #post_build, #rawdata, #rawdata=, #real_type, #set_predictor, #to_obfuscated_str, #to_s, #value
Methods included from Object
#<=>, #copy, #indirect_parent, #is_indirect?, parse, #pdf, #pdf_version_required, #post_build, #reference, #set_indirect, #set_pdf, #size, skip_until_next_obj, #solve, #to_o, #to_s, #type, typeof, #xrefs
Constructor Details
#initialize(data = "", dictionary = {}) ⇒ XRefStream
Returns a new instance of XRefStream.
333 334 335 336 337 |
# File 'lib/origami/xreftable.rb', line 333 def initialize(data = "", dictionary = {}) super(data, dictionary) @xrefs = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Origami::Stream
Instance Method Details
#<<(xref) ⇒ Object
Adds an XRef to this Stream.
362 363 364 365 366 |
# File 'lib/origami/xreftable.rb', line 362 def <<(xref) load! if @xrefs.nil? @xrefs << xref end |
#clear ⇒ Object
397 398 399 400 401 |
# File 'lib/origami/xreftable.rb', line 397 def clear self.data = '' @xrefs = [] self.Index = [] end |
#each(&b) ⇒ Object
Iterates over each XRef present in the stream.
371 372 373 374 375 |
# File 'lib/origami/xreftable.rb', line 371 def each(&b) load! if @xrefs.nil? @xrefs.each(&b) end |
#entries ⇒ Object
339 340 341 342 343 |
# File 'lib/origami/xreftable.rb', line 339 def entries load! if @xrefs.nil? @xrefs end |
#find(no) ⇒ Object
Returns an XRef matching this object number.
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 |
# File 'lib/origami/xreftable.rb', line 380 def find(no) load! if @xrefs.nil? ranges = self.Index || [ 0, @xrefs.length ] index = 0 (ranges.size / 2).times do |i| brange = ranges[i*2].to_i size = ranges[i*2+1].to_i return @xrefs[index + no - brange] if Range.new(brange, brange + size - 1) === no index += size end nil end |
#pre_build ⇒ Object
Returns XRef entries present in this stream.
348 349 350 351 352 353 354 355 356 357 |
# File 'lib/origami/xreftable.rb', line 348 def pre_build #:nodoc: load! if @xrefs.nil? self.W = [ 1, 2, 2 ] unless has_field?(:W) self.Size = @xrefs.length + 1 save! super end |