MergeDocumentEx

Document manipulation, forms

Description

Joins another document to the selected document while applying an explicit policy to duplicate top-level form-field names

The duplicate-name preflight completes before object numbers, page trees or form arrays are changed, so a rejected source document remains open and reusable

Syntax

Delphi

Function TPDFlib.MergeDocumentEx(DocumentID: Integer; DuplicateFieldStrategy: TPDFlibDuplicateFieldStrategy): Integer;

Parameters

DocumentIDThe ID of the document to append to the selected document
DuplicateFieldStrategydfsReject, dfsMerge or dfsAutoNumber

Strategies

dfsRejectRejects the operation when a source root field name already exists and leaves both documents unchanged
dfsMergePreserves the shared field name and applies the target field value and default value to the imported field, allowing conforming viewers to treat the widgets as one logical field
dfsAutoNumberRenames each conflicting source root field with the first available deterministic suffix such as _2 or _3

Return values

Returns 1 after a successful merge or 0 when validation or merging fails

A duplicate rejected by dfsReject sets LastErrorCode to 705

Remarks

A successful merge removes the source document from the document collection, matching MergeDocument

MergeDocument retains its legacy duplicate-field behaviour for compatibility

See also

MergeDocument, TPDFlibDuplicateFieldStrategy