Automation extensions

Integration and compatibility

Description

The COM automation interfaces extend IPDFlibrary with renderer configuration, form-script execution, HTML and SVG import diagnostics, archival conversion, text reflow, VCR merge and legal-attestation seed values, while keeping earlier IIDs, method order and dispatch identifiers unchanged. Use the interface levels and CoPDFlibrary factory methods below to pick the typed extension a late-bound or early-bound caller needs, and to see which edition gates each added method.

Compatible interfaces

IPDFlibrary2 inherits IPDFlibrary and adds legal-attestation seed values, metafile diagnostics and complete external-file VCR merge arguments (ExecuteVCRDataMergeEx — Small Business edition)

The original IPDFlibrary IID, method order and dispatch identifiers remain unchanged; existing DLL names, ordinals and argument lists remain available

IPDFlibrary3 inherits IPDFlibrary2 and adds renderer configuration: SetCairoFileName, SetPDFiumFileName, SelectedRenderer and GetRenderCapabilities

IPDFlibrary4 inherits IPDFlibrary3 and adds the form-script runtime: ExecuteFormFieldScriptJSON, ExecuteFormFieldTriggerScript, ExecutePageScript, ExecuteDocumentScript, SetFormScriptLimits, GetFormScriptLimitsJSON, GetFormScriptDiagnostics, SetFormScriptHostActionMode, GetFormScriptHostActionMode, RecalculateFormFields and GetFormCalculationGraphJSON

IPDFlibrary5 inherits IPDFlibrary4 and adds document operations that were previously available only to Delphi and DLL callers: OptimizeEmbeddedFonts, GetLastFontOptimizationJSON, AddActionNextWeb, AddActionNextNamed, AddActionNextJavaScript, GetActionNextCount, AddLinkToHideField, AddLinkToImportData, AddLinkToNamedAction, AddLinkToNamedDestination, SetFormFieldAction, LoadOutputIntentProfile, SetPDFA3DefaultAFRelationship, DAOpenFileWithEncryptionKey, DAGetEncryptionKeyValidation and SetMemoryBudget. They take the same parameters as the Delphi methods; SetMemoryBudget takes a 64-bit stream size

The Automation type library is version 3.6, independently of the product version; its default dispatch interface is IPDFlibrary18. IPDFlibrary2, IPDFlibrary3 and IPDFlibrary4 keep their IIDs, methods and dispatch identifiers

Existing Pascal CoPDFlibrary.Create and CreateRemote helpers retain their IPDFlibrary return type; CreateExtended returns IPDFlibrary2 and CreateRenderer returns IPDFlibrary3, CreateFormScript returns IPDFlibrary4, CreateDocumentTools returns IPDFlibrary5, and existing objects can also be queried for any extended interface

Extended := CoPDFlibrary.CreateExtended;
Extended.SetSignatureFieldSeedValueEx(1, 16, '', '', '', 'Approved;Final');

Late-bound Automation clients can discover the new method names through the default IDispatch interface

Conversion and recognition capabilities

IPDFlibrary16 inherits IPDFlibrary15 and adds DrawHTMLPages, GetLastHTMLImportDiagnostics, DrawSVGEx, GetLastSVGImportDiagnostics, GetSVGFilterCapabilitiesJSON and GetBarcodeReaderCapabilitiesJSON; professional barcode generation (DrawRMQRCode, DrawGS1DataBarLimited, DrawGS1DataBarExpanded, DrawMaxiCode on IPDFlibrary7) requires the Small Business edition

Use CoPDFlibrary.CreateConversionTools for the typed interface; late-bound callers use the default IDispatch interface, and all earlier interface IIDs, method orders and dispatch identifiers remain unchanged

Archival conversion fidelity (Enterprise edition)

IPDFlibrary17 inherits IPDFlibrary16 and adds ConvertToPDFAEx (Enterprise edition) with explicit TargetMode, FidelityPolicy and DPI arguments; CoPDFlibrary.CreateArchivalTools returns the typed extension, and the new method is available through default IDispatch

Verified text box reflow

IPDFlibrary18 inherits IPDFlibrary17 and adds SearchAndReflowTextInContent with explicit box dimensions, font size, line height, minimum size, replacement and fallback font IDs and an overflow policy; CoPDFlibrary.CreateTextReflowTools returns the typed extension

Renderer configuration

Renderer := CoPDFlibrary.CreateRenderer;
if Renderer.SetCairoFileName('C:\Cairo\cairo.dll') = 1 then
  Renderer.SelectRenderer(2);
Writeln(Renderer.GetRenderCapabilities(1));

SetCairoFileName and SetPDFiumFileName return 1 when the library loads and 0 otherwise; SelectedRenderer returns 1 for the built-in renderer, 2 for Cairo and 3 for PDFium

Legal-attestation seed values

int DLSetSignatureFieldSeedValueEx(int InstanceID, int Index, int Flags,
  const wchar_t* SubFilters, const wchar_t* DigestMethods,
  const wchar_t* Reasons, const wchar_t* LegalAttestations);
int DLSetSignatureFieldSeedValueExA(int InstanceID, int Index, int Flags,
  const char* SubFilters, const char* DigestMethods,
  const char* Reasons, const char* LegalAttestations);

The extended Automation method has the same arguments without InstanceID

Index is the one-based unsigned signature field index; semicolon-delimited LegalAttestations supplies the /LegalAttestation constraint, with flag 16 making it required

Return values and other constraints follow SetSignatureFieldSeedValue; the original facade methods retain an empty LegalAttestations default

Delphi callers continue to use the existing optional LegalAttestations argument of TPDFlib.SetSignatureFieldSeedValue

Metafile diagnostics

const wchar_t* DLGetLastMetafileDiagnostics(int InstanceID);
const char* DLGetLastMetafileDiagnosticsA(int InstanceID);

IPDFlibrary2.GetLastMetafileDiagnostics returns the same JSON as the Delphi getter; it does not initiate an import

An invalid instance returns a null DLL pointer; DLL instance zero retains its existing default-instance meaning

DLL strings belong to the instance return buffer and must be copied before another call reuses that buffer; A entry points follow the configured ANSI or UTF-8 mode

External-file VCR merge (Small Business edition)

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);

IPDFlibrary2.ExecuteVCRDataMergeEx (Small Business edition) accepts the same four string arguments without InstanceID and forwards the Delphi external-file merge contract; in the Single edition it returns 0 and sets LastErrorCode 901

Current-document VCR merge (Small Business edition)

Function TPDFlib.ExecuteVCRDataMergeCurrent(
  Const FieldValues: WideString; Options: Integer): Integer;

The original DLL and Automation ExecuteVCRDataMerge entry points retain their FieldValuesJSON and Options argument lists and now use this current-document route (Small Business edition; returns 0 with LastErrorCode 901 in the Single edition)

FieldValues uses the merge engine's JSON object or semicolon-delimited name=value syntax; Options must be zero

The selected template is saved and validated in memory, merged and loaded as a new selected document only on success

The original document remains open and can be selected again using its earlier SelectedDocument handle; failure does not select a partial merged document

The return value is 1 on success and 0 on failure; unsupported Options or a template/merge failure reports LastErrorCode 608, while save or load errors retain their existing diagnostics

DataBar selector

Function TPDFlib.DrawGS1DataBarEx(Left, Top, Width, Height: Double;
  Const Text: WideString; Variant, Options: Integer): Integer;

The existing DLL and Automation DrawGS1DataBar methods retain their Variant argument and forward this route

Only Variant zero is supported and selects the existing Omnidirectional encoder; any other value returns 0 with LastErrorCode 301

The original Delphi DrawGS1DataBar method keeps its existing signature and behavior