API referenceCore SDK

pdfSetOnErrorProc

Register a callback invoked live for each raised error.

CategoryError handling
Thread safetyCallback fires on whichever thread raises the error.

Purpose — Register a callback invoked live for each raised error.

Description — Stores the user Data pointer and the TErrorProc on the instance. Whenever RaiseError runs and the error's class passes the error-mode filter, the callback fires after the message is appended to the indexed log, receiving (Data, ErrCode, Msg, ErrType). Passing a nil proc disables the callback (the log surfaces are unaffected).

Declarations

C
typedef void (__stdcall *TErrorProc)(void* Data, int32_t ErrCode,
                                     const char* Msg, int32_t ErrType);
BOOL32 __stdcall pdfSetOnErrorProc(PPDF IPDF, void* Data, TErrorProc ErrProc);
Delphi
type TErrorProc = procedure(Data: Pointer; ErrCode: Integer;
                            Msg: PAnsiChar; ErrType: Integer); stdcall;
function pdfSetOnErrorProc(const IPDF: PPDF; const Data: Pointer; ErrProc: TErrorProc): LongBool; stdcall; external 'LumasPdf.dll';

Parameters

ParameterTypeDescription
IPDFPPDFInstance handle.
Datavoid*Opaque context echoed back to your callback.
ErrProcTErrorProcCallback, or nil to detach.

Return valueTRUE on a valid handle; FALSE otherwise.

Memory & buffersMsg inside the callback is owned by the engine and valid only for the duration of the call; copy it if you need to keep it.

Remarks — The callback is fired only for errors whose class passes the current error mode; emIgnoreAll silences it entirely. Keep the handler fast and reentrancy-safe — it runs inside the engine call that raised the error.

Example — Delphi (production)

Delphi
procedure MyErr(Data: Pointer; ErrCode: Integer; Msg: PAnsiChar; ErrType: Integer); stdcall;
begin
  Writeln(Format('[%d/%d] %s', [ErrCode, ErrType, string(AnsiString(Msg))]));
end;

var P: PPDF;
begin
  P := pdfNewPDF;
  try
    pdfSetErrorMode(P, Integer($0000FFFF));   // emAllErrors
    pdfSetOnErrorProc(P, nil, @MyErr);
    // ... build document; any engine error now prints live ...
  finally
    pdfDeletePDF(P);
  end;
end;

See alsopdfGetErrLogMessage, pdfSetErrorMode

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Core SDK
Category

Setters

Exported names

pdfSetOnErrorProc

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.