Skip to content

happypdf / PDFObjectCopier

Class: PDFObjectCopier

Defined in: src/core/PDFObjectCopier.ts:31

PDFObjectCopier copies PDFObjects from a src context to a dest context. The primary use case for this is to copy pages between PDFs.

Copying an object with a PDFObjectCopier is different from cloning an object with its [[PDFObject.clone]] method:

  const src: PDFContext = ...
  const dest: PDFContext = ...
  const originalObject: PDFObject = ...
  const copiedObject = PDFObjectCopier.for(src, dest).copy(originalObject);
  const clonedObject = originalObject.clone();

Copying an object is equivalent to cloning it and then copying over any other objects that it references. Note that only dictionaries, arrays, and streams (or structures build from them) can contain indirect references to other objects. Copying a PDFObject that is not a dictionary, array, or stream is supported, but is equivalent to cloning it.

Methods

copy()

ts
copy<T>(object): T;

Defined in: src/core/PDFObjectCopier.ts:45

Type Parameters

Type Parameter
T extends PDFObject

Parameters

ParameterType
objectT

Returns

T


for()

ts
static for(src, dest): PDFObjectCopier;

Defined in: src/core/PDFObjectCopier.ts:32

Parameters

ParameterType
srcPDFContext
destPDFContext

Returns

PDFObjectCopier

MIT Licensed. A fork of pdf-lib.