Class: RPDF::CrossRefTable
- Inherits:
-
Object
- Object
- RPDF::CrossRefTable
- 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
- #addUsedEntry(position, objectnumber) ⇒ Object
-
#initialize ⇒ CrossRefTable
constructor
A new instance of CrossRefTable.
- #size ⇒ Object
- #to_pdf ⇒ Object
Constructor Details
#initialize ⇒ CrossRefTable
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 |
#size ⇒ Object
17 18 19 |
# File 'lib/rpdf/crossreftable.rb', line 17 def size @hash.size + 1 end |
#to_pdf ⇒ Object
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 |