ExecuteVCRDataMerge

Compliance, variable content, document editing

Requires the Small Business edition. In Delphi, C++Builder and Lazarus code create the library as TPDFlibSmallBusiness (unit PDFlibSmallBusiness) or TPDFlibEnterprise; the Small Business and Enterprise DLL and ActiveX builds provide it unchanged. The Single edition keeps the method, which returns 0 and sets LastErrorCode to 901 (PDFLIB_ERROR_SMALLBUSINESS_REQUIRED)

Description

Executes an ISO 16613-1 (PDF/VCR-1) variable content replacement merge on an external template PDF and writes the merged document to a file

JSON field names and values use standard JSON string escapes, including Unicode escapes; an explicit empty string clears its placeholder, whilst an absent field leaves its placeholder unchanged; failed merges preserve an existing output file

Syntax

Delphi

Function ExecuteVCRDataMerge(Const InputFileName, Password, FieldValues, OutputFileName: WideString): Integer; Virtual;

ActiveX

Function PDFlib::ExecuteVCRDataMergeEx(InputFileName As String, Password As String, FieldValues As String, OutputFileName As String) As Long

DLL

int DLExecuteVCRDataMergeEx(int InstanceID, const wchar_t* InputFileName, const wchar_t* Password, const wchar_t* FieldValues, const wchar_t* OutputFileName);
int DLExecuteVCRDataMergeExA(int InstanceID, const char* InputFileName, const char* Password, const char* FieldValues, const char* OutputFileName);

Parameters

InputFileNameFull path of the PDF/VCR template to read
PasswordPassword used to open the template, or an empty string for an unencrypted file
FieldValuesKey-value pairs (Key=Value separated by semicolons or newlines, or a JSON object) mapping declared GTS_Data field names to replacement text
OutputFileNameDestination file path for the merged PDF output

Return values

1 when the chosen merge contract completes successfully, otherwise 0; external-file methods write OutputFileName, while current-document methods select a new merged document

Remarks

The original entry points, PDFlib::ExecuteVCRDataMerge in ActiveX and DLExecuteVCRDataMerge in the DLL and the Dylib, merge the currently selected template and select a new merged document, preserving the original document; Options must be zero, with ExecuteVCRDataMergeCurrent documenting that contract

ExecuteVCRDataMergeEx — reached from ActiveX as PDFlib::ExecuteVCRDataMergeEx and from the DLL and the Dylib as DLExecuteVCRDataMergeEx — exposes the complete external-file contract described on this page

Each placeholder structure element carrying a GTS_Replacement attribute dictionary and matching GTS_Data field name has its corresponding marked-content sequence (/Span << /MCID ... >> BDC ... EMC) updated in the page content stream

A missing input file or empty output path sets LastErrorCode 401; a template validation or merge failure sets LastErrorCode 608

Field values keep their full Unicode text and are written with the font in effect at each placeholder; a JSON null value clears the placeholder, and a value containing a character the template font cannot display fails the merge with LastErrorCode 608 whilst leaving an existing output file untouched

See also

ExecuteVCRDataMergeCurrent, BeginPDFVCRTemplate, BeginPDFVCRPlaceholder, GetPDFVCRManifest