API referenceImages

pdfInsertMetafileFromHandleEx

Replay a live, in-process GDI HENHMETAFILE handle

C
BOOL32 __stdcall pdfInsertMetafileFromHandle(PPDF IPDF, void* hEnhMetafile, double PosX, double PosY, double Width, double Height);
BOOL32 __stdcall pdfInsertMetafileFromHandleEx(PPDF IPDF, void* hEnhMetafile, TRectL* View, double PosX, double PosY, double Width, double Height);
Delphi
function pdfInsertMetafileFromHandle(const IPDF: PPDF; hEnhMetafile: Pointer; PosX, PosY, Width, Height: Double): LongBool; stdcall;
function pdfInsertMetafileFromHandleEx(const IPDF: PPDF; hEnhMetafile: Pointer; View: PRectL; PosX, PosY, Width, Height: Double): LongBool; stdcall;

Purpose. Replay a live, in-process GDI HENHMETAFILE handle (e.g. one just captured from a TMetafile/GDI recording session) directly, without round-tripping it through a file or byte buffer first.

Description. Converts the live GDI handle to EMF record bytes in-process (ViewerHEnhMetafileToBytes), then replays through the same DrawEMFMetafile engine as every other function in this chapter. Ex's View parameter is, again, accepted but never read (documented as an "optional viewport hint" in the source, with the same rationale — the EMF header's own frame drives placement regardless).

Parameters.

ParameterDescription
IPDFDocument handle.
hEnhMetafileA live GDI HENHMETAFILE handle (Windows-only; caller retains ownership — this call reads it, does not take it over).
View*(Ex only)* Accepted but never read.
PosX, PosY, Width, HeightTarget placement box.

Return value. True on success; False if IPDF is invalid, the handle could not be converted to EMF bytes, or the replay engine failed to parse the result.

See also. pdfInsertMetafile.

C# (P/Invoke)

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

Metafiles

Exported names

pdfInsertMetafileFromHandleEx

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.