...master 2026-11-10 (4e7201cfc+unstaged)

PDFGraftMap

The graft map is a structure used to copy objects between different PDF documents, and track which objects have already been copied so that they can be re-used.

Constructors

class PDFGraftMap()

You cannot create instances of this class with the new operator!

Call PDFDocument.prototype.newGraftMap to create a graft map.

Instance methods

PDFGraftMap.prototype.graftObject(obj)

Return a deep copy of the given object suitable for use within the graft map’s target document.

var map = document.newGraftMap()
map.graftObject(obj)

PDFGraftMap.prototype.graftPage(to, srcDoc, srcPage)

Graft a page and its resources at the given page number from the source document to the requested page number in the destination document connected to the map.

Page numbers start at 0 and -1 means at the end of the document.

var map = dstdoc.newGraftMap()
map.graftObject(-1, srcdoc, 0)