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
| DocumentID | The ID of the document to append to the selected document |
|---|---|
| DuplicateFieldStrategy | dfsReject, dfsMerge or dfsAutoNumber |
Strategies
| dfsReject | Rejects the operation when a source root field name already exists and leaves both documents unchanged |
|---|---|
| dfsMerge | Preserves 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 |
| dfsAutoNumber | Renames 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