| Category | Error handling |
|---|---|
| Thread safety | Callback 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
typedef void (__stdcall *TErrorProc)(void* Data, int32_t ErrCode,
const char* Msg, int32_t ErrType);
BOOL32 __stdcall pdfSetOnErrorProc(PPDF IPDF, void* Data, TErrorProc ErrProc);
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
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle. |
Data | void* | Opaque context echoed back to your callback. |
ErrProc | TErrorProc | Callback, or nil to detach. |
Return value — TRUE on a valid handle; FALSE otherwise.
Memory & buffers — Msg 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)
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 also — pdfGetErrLogMessage, pdfSetErrorMode
C# (P/Invoke)
[return: MarshalAs(UnmanagedType.Bool)]
Setters
pdfSetOnErrorProc
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.