class HexaPDF::CLI::Inspect
def revision_information
- The signature dictionary if this revision was signed
- The number of objects in the revision
- The index of the revision in terms of all revisions of the document
- The revision object itself
Returns an array of arrays that include the following information:
Yields information about the document's revisions.
def revision_information signatures = @doc.signatures.to_h do |sig| [@doc.revisions.find {|rev| rev.object(sig) == sig }, sig] end io = @doc.revisions.parser.io io.seek(0, IO::SEEK_END) startxrefs = @doc.revisions.map {|rev| rev.trailer[:Prev].to_i } << @doc.revisions.parser.startxref_offset << io.pos startxrefs.sort! startxrefs.shift @doc.revisions.each_with_index.map do |rev, index| end_index = 0 sig = signatures[rev] if sig end_index = sig[:ByteRange][-2] + sig[:ByteRange][-1] else io.seek(startxrefs[index], IO::SEEK_SET) buffer = ''.b while io.pos < startxrefs[index + 1] buffer << io.read(1_000) if (buffer_index = buffer.index(/(?:\n|\r\n?)\s*%%EOF\s*(?:\n|\r\n?)?/)) end_index = io.pos - buffer.size + buffer_index + $~[0].size break end buffer = buffer[-20..-1] end end yield(rev, index, rev.each.count, sig, end_index) end end