API referenceForms

pdfGetXFALastError

Drive the XFA dynamic-form engine explicitly: render the

C
SI32 __stdcall pdfRenderXFAForm(PPDF IPDF);
SI32 __stdcall pdfXFAFormPageCount(PPDF IPDF);
SI32 __stdcall pdfSetXFARenderMode(PPDF IPDF, SI32 Mode);
SI32 __stdcall pdfSetXFAExpandMode(PPDF IPDF, SI32 Mode);
SI32 __stdcall pdfSetXFAScriptEnabled(PPDF IPDF, SI32 Enabled);
SI32 __stdcall pdfGetXFALastErrorA(PPDF IPDF, char* Buf, SI32 BufLen);
SI32 __stdcall pdfGetXFALastErrorW(PPDF IPDF, wchar_t* Buf, SI32 BufLen);
Delphi
function pdfRenderXFAForm(const IPDF: PPDF): Integer; stdcall;
function pdfXFAFormPageCount(const IPDF: PPDF): Integer; stdcall;
function pdfSetXFARenderMode(const IPDF: PPDF; Mode: Integer): Integer; stdcall;
function pdfSetXFAExpandMode(const IPDF: PPDF; Mode: Integer): Integer; stdcall;
function pdfSetXFAScriptEnabled(const IPDF: PPDF; Enabled: Integer): Integer; stdcall;
function pdfGetXFALastErrorA(const IPDF: PPDF; Buf: PAnsiChar; BufLen: Integer): Integer; stdcall;
function pdfGetXFALastErrorW(const IPDF: PPDF; Buf: PWideChar; BufLen: Integer): Integer; stdcall;

Purpose. Drive the XFA dynamic-form engine explicitly: render the imported XFA form into PDF pages, pre-flight its page count, choose render/expand behavior, control scripting, and read the engine's last error message.

Purpose of each.

FunctionWhat it does
pdfRenderXFAFormRuns the XFA engine over the open import's XFA package and lays the form out into regular PDF pages in the current document.
pdfXFAFormPageCountPre-flight: how many pages the render WOULD produce, without producing them.
pdfSetXFARenderMode0/1: selects the render mode. Returns the PREVIOUS mode; -3 for an out-of-range value.
pdfSetXFAExpandMode0/1: selects how growable subforms expand. Returns the PREVIOUS mode; -3 for an out-of-range value.
pdfSetXFAScriptEnabledEnables (<>0) or disables (0) XFA script execution during the render. Returns the PREVIOUS state as 0/1.
pdfGetXFALastErrorA/WCopies the engine's last error text into Buf and returns its length; a two-call size-then-fetch pattern works with a NULL buffer.

Return value. pdfRenderXFAForm and pdfXFAFormPageCount answer a page count, or a negative engine error code (read the message via pdfGetXFALastError); -1 also covers an invalid document handle. The mode setters and the error query answer as listed above.

See also. the XFA form-field property calls documented earlier in this chapter (pdfGetXFAFormFieldValue and family).

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfGetXFALastErrorW(IntPtr IPDF, IntPtr Buf, int BufLen);
public static extern int pdfGetXFALastErrorA(IntPtr IPDF, IntPtr Buf, int BufLen);
Area
Forms
Category

Getters

Exported names

pdfGetXFALastErrorW pdfGetXFALastErrorA

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.