Class: RPDF::CrossRefTable

Inherits:
Object
  • Object
show all
Defined in:
lib/rpdf/crossreftable.rb

Overview

Cross-Reference Table This implementation uses only one cross-reference section and no free entries.

PDFRef15 p69

Instance Method Summary collapse

Constructor Details

#initializeCrossRefTable

Returns a new instance of CrossRefTable.



9
10
11
# File 'lib/rpdf/crossreftable.rb', line 9

def initialize
  @hash = Hash.new
end

Instance Method Details

#addUsedEntry(position, objectnumber) ⇒ Object



13
14
15
# File 'lib/rpdf/crossreftable.rb', line 13

def addUsedEntry(position, objectnumber)
  @hash[objectnumber] = position
end

#sizeObject



17
18
19
# File 'lib/rpdf/crossreftable.rb', line 17

def size
  @hash.size + 1
end

#to_pdfObject



21
22
23
24
25
26
27
28
29
# File 'lib/rpdf/crossreftable.rb', line 21

def to_pdf
  bytes = "xref\n"
  bytes << "0 #{size}\n"
  bytes << "0000000000 65535 f \n"
  @hash.keys.sort.each { |objectnumber|
    bytes << ("%010d" % @hash[objectnumber]) << " 00000 n \n"
  }
  bytes << "\n"
end