class HexaPDF::Importer


The Importer class manages the process of copying objects from one Document to another.

It may seem unnecessary using an importer containing state for the task. However, by retaining some information about the already copied objects we can make sure that already imported objects don't get imported again.

Two types of indirect objects are never imported from one document to another: the catalog and page tree nodes. If the catalog was imported, the whole source document would be imported. And if one page tree node would imported, the whole page tree would be imported.

See: Document#import

Public Class Methods

for(source:, destination:)

Returns the Importer object for copying objects from the source to the destination document.

new(source:, destination:)

Initializes a new importer that can import objects from the source document to the destination document.

Public Instance Methods


Imports the given object from the source to the destination object and returns the imported object.

Note: Indirect objects are automatically added to the destination document but direct or simple objects are not.

An error is raised if the object doesn't belong to the source document.