API referenceAnnotations

pdfRichMediaAnnot

Create a RichMedia annotation embedding an external media file

C
int32_t __stdcall pdfRichMediaAnnotA(PPDF IPDF, double PosX, double PosY, double Width, double Height, int32_t AType, const char* FileName);
int32_t __stdcall pdfRichMediaAnnotW(PPDF IPDF, double PosX, double PosY, double Width, double Height, int32_t AType, const wchar_t* FileName);
Delphi
function pdfRichMediaAnnotA(const IPDF: PPDF; PosX, PosY, Width, Height: Double; AType: Integer; const FileName: PAnsiChar): Integer; stdcall;
function pdfRichMediaAnnotW(const IPDF: PPDF; PosX, PosY, Width, Height: Double; AType: Integer; const FileName: PWideChar): Integer; stdcall;

Purpose. Create a RichMedia annotation embedding an external media file (Flash/video/3D, per AType).

Description. If FileName resolves to an existing file, its bytes are read and embedded along with its base filename; if the file doesn't exist, the annotation is still created via RichMediaAnnotH but with empty content data (data=''), rather than failing the call outright — the existence check only controls whether content gets attached, not whether annotation creation itself succeeds.

Parameters.

ParameterDescription
IPDFDocument handle.
PosX, PosY, Width, HeightBounding box.
ATypeRich-media content-type selector, passed through as-is.
FileNamePath to the media file; a non-existent path silently yields an empty-content annotation rather than a failure.

Return value. The new annotation's handle; -1 if IPDF is invalid.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfRichMediaAnnotA(IntPtr IPDF, double PosX, double PosY, double Width, double Height, int AType, [MarshalAs(UnmanagedType.LPStr)] string FileName);
public static extern int pdfRichMediaAnnotW(IntPtr IPDF, double PosX, double PosY, double Width, double Height, int AType, [MarshalAs(UnmanagedType.LPWStr)] string FileName);
Area
Annotations
Category

Core

Exported names

pdfRichMediaAnnotA pdfRichMediaAnnotW

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.