class HexaPDF::Revision

Parent
Included Modules

Embodies one revision of a PDF file, either the initial version or an incremental update.

The purpose of a Revision object is to manage the objects and the trailer of one revision. These objects can either be added manually or loaded from a cross-reference section or stream. Since a PDF file can be incrementally updated, it can have multiple revisions.

If a revision doesn't have an associated cross-reference section, it wasn't created from a PDF file.

See: PDF1.7 s7.5.6, Revisions

Attributes

loader[RW]

The callable object responsible for loading objects.

trailer[R]

The trailer dictionary

Public Class Methods

new(trailer) → revision
new(trailer, xref_section: section, loader: loader) → revision
new(trailer, xref_section: section) {|entry| block } → revision

Creates a new Revision object.

Options:

xref_section

An XRefSection object that contains information on how to load objects. If this option is specified, then a loader or a block also needs to be specified!

loader

The loader object needs to respond to call taking a cross-reference entry and returning the loaded object. If no xref_section is supplied, this value is not used.

If a block is given, it is used instead of the loader object.

Public Instance Methods

add(obj) → obj

Adds the given object (needs to be a HexaPDF::Object) to this revision and returns it.

delete(ref, mark_as_free: true)
delete(oid, mark_as_free: true)

Deletes the object specified either by reference or by object number from this revision by marking it as free.

If the mark_as_free option is set to false, the object is really deleted.

each {|obj| block } → revision
each → Enumerator

Calls the given block once for every object of the revision.

Objects that are loadable via an associated cross-reference section but are currently not, are loaded automatically.

next_free_oid()

Returns the next free object number for adding an object to this revision.

object(ref) → obj or nil
object(oid) → obj or nil

Returns the object for the given reference or object number if such an object is available in this revision, or nil otherwise.

If the revision has an entry but one that is pointing to a free entry in the cross-reference section, an object representing PDF null is returned.

object?(ref) → true or false
object?(oid) → true or false

Returns true if the revision contains an object

  • for the exact reference if the argument responds to :oid, or else

  • for the given object number.