class HexaPDF::Revisions

Parent
Included Modules

Manages the revisions of a PDF document.

A PDF document has one revision when it is created. Later, new revisions are added when changes are made. This allows for adding information/content to a PDF file without changing the original content.

The order of the revisions is important. In HexaPDF the oldest revision always has index 0 and the newest revision the highest index. This is also the order in which the revisions get written.

See: PDF1.7 s7.5.6, HexaPDF::Revision

Public Class Methods

from_io(document, io)

Loads all revisions for the document from the given IO and returns the created Revisions object.

If the io object is nil, an empty Revisions object is returned.

new(document, initial_revisions: nil)

Creates a new revisions object for the given PDF document.

Options:

initial_revisions

An array of revisions that should initially be used. If this option is not specified, a single empty revision is added.

Public Instance Methods

[](index)
Alias for: revision
add()

Adds a new empty revision to the document and returns it.

current()

Returns the current revision.

delete(index) → rev or nil
delete(oid) → rev or nil

Deletes a revision from the document, either by index or by specifying the revision object itself.

Returns the deleted revision object, or nil if the index was out of range or no matching revision was found.

Regarding the index: The oldest revision has index 0 and the current revision the highest index!

each {|rev| block } → revisions
each → Enumerator

Iterates over all revisions from oldest to current one.

merge(range = 0..-1) → revisions

Merges the revisions specified by the given range into one. Objects from newer revisions overwrite those from older ones.

revision(index)

Returns the revision at the specified index.

Also aliased as: []
size()

Returns the number of HexaPDF::Revision objects managed by this object.