API referenceImages

pdfInsertMetafile

Replay an EMF/WMF metafile file (A/W) or in-memory buffer

C
BOOL32 __stdcall pdfInsertMetafileA(PPDF IPDF, const char* FileName, double PosX, double PosY, double Width, double Height);
BOOL32 __stdcall pdfInsertMetafileW(PPDF IPDF, const wchar_t* FileName, double PosX, double PosY, double Width, double Height);
BOOL32 __stdcall pdfInsertMetafileEx(PPDF IPDF, void* Buffer, uint32_t BufSize, double PosX, double PosY, double Width, double Height);
Delphi
function pdfInsertMetafileA(const IPDF: PPDF; const FileName: PAnsiChar; PosX, PosY, Width, Height: Double): LongBool; stdcall;
function pdfInsertMetafileW(const IPDF: PPDF; const FileName: PWideChar; PosX, PosY, Width, Height: Double): LongBool; stdcall;
function pdfInsertMetafileEx(const IPDF: PPDF; Buffer: Pointer; BufSize: Cardinal; PosX, PosY, Width, Height: Double): LongBool; stdcall;

Purpose. Replay an EMF/WMF metafile file (A/W) or in-memory buffer (Ex) onto the current page as real PDF vector drawing operators — not a rasterized bitmap.

Description. Reads the whole file (A/W, failing if it doesn't exist) or uses the caller's buffer directly (Ex, failing on a null/empty buffer), then replays the metafile's GDI drawing records through DrawEMFMetafile, which maps the metafile's own embedded logical bounds onto the PosX/PosY/Width/Height placement box on the current page. Because this is a genuine record-by-record replay (not a bitmap capture), the resulting PDF content is real, scalable vector graphics/text wherever the source metafile itself used vector GDI calls.

Parameters.

ParameterDescription
IPDFDocument handle.
FileName*(A/W)* Path to an .emf (or .wmf) file.
Buffer, BufSize*(Ex)* In-memory metafile record bytes.
PosX, PosY, Width, HeightTarget placement box on the current page — the metafile's own bounds are mapped onto this box.

Return value. True on success; False if IPDF is invalid, the file doesn't exist / the buffer is empty, or the replay engine could not parse the metafile records.

See also. pdfInsertMetafileExt, pdfGetLogMetafileSize.

C# (P/Invoke)

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

Metafiles

Exported names

pdfInsertMetafile pdfInsertMetafileA pdfInsertMetafileW

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.