CopyForeignObject

Document parts

Description

Deep-copies one indirect object and its reference closure from another loaded document

Syntax

Delphi

Function CopyForeignObject(SourceDocumentID, ObjectNumber: Integer): Integer;

Return values

0No target document, invalid source handle or object number, or the source is the selected document itself
HandleHandle of the new indirect object holding the copied content

Remarks

Every indirect reference reachable from the source object is copied with it, and source object numbers are remapped through a live map so objects referenced twice stay shared in the copy. Dictionaries, arrays, streams (with their filter dictionaries), names, strings and numbers all round-trip. Cyclic back-references such as page /Parent and outline /Prev resolve to null in the copy; use ImportPageAsFormXObject when the page tree structure itself must be preserved.

Example

NewRef:= PDF.CopyForeignObject(StampDocID, 12);

See also

ImportPageAsFormXObject, GetDocumentID