API referenceAnnotations

pdfCreate3DAnnot

Create a 3D annotation embedding a U3D model file.

C
int32_t __stdcall pdfCreate3DAnnotA(PPDF IPDF, double PosX, double PosY, double Width, double Height, const char* Author, const char* AnnotName, const char* U3DFile, const char* ImageFile);
int32_t __stdcall pdfCreate3DAnnotW(PPDF IPDF, double PosX, double PosY, double Width, double Height, const wchar_t* Author, const wchar_t* AnnotName, const wchar_t* U3DFile, const wchar_t* ImageFile);
Delphi
function pdfCreate3DAnnotA(const IPDF: PPDF; PosX, PosY, Width, Height: Double; const Author, AnnotName, U3DFile, ImageFile: PAnsiChar): Integer; stdcall;
function pdfCreate3DAnnotW(const IPDF: PPDF; PosX, PosY, Width, Height: Double; const Author, AnnotName, U3DFile, ImageFile: PWideChar): Integer; stdcall;

Purpose. Create a 3D annotation embedding a U3D model file.

Description. Loads U3DFile (Lumas_Load3DModel, which also returns the appropriate /Subtype string for the 3D stream); fails outright if loading returns empty bytes. ImageFile — presumably intended as a 2D poster/preview image shown before the 3D view activates — is accepted by the ABI but never passed to Add3DAnnot, and has no effect whatsoever. There is no fallback poster image generated or attached through this call; if a poster image is required, it must be set through some other mechanism not covered by this entry point (not independently located in this chapter).

Parameters.

ParameterDescription
IPDFDocument handle.
PosX, PosY, Width, HeightBounding box.
Author, AnnotName/T, annotation name.
U3DFilePath to a .u3d model file; required, load failure fails the call.
ImageFileAccepted but never read — has no effect.

Return value. The new annotation's handle; 0 if IPDF is invalid or U3DFile failed to load.

See also. pdfSet3DAnnotProps, pdfGet3DAnnotStream.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
public static extern int pdfCreate3DAnnot(IntPtr IPDF, double PosX, double PosY, double Width, double Height, [MarshalAs(UnmanagedType.LPStr)] string Author, [MarshalAs(UnmanagedType.LPStr)] string AnnotName, [MarshalAs(UnmanagedType.LPStr)] string U3DFile, [MarshalAs(UnmanagedType.LPStr)] string ImageFile);
public static extern int pdfCreate3DAnnotA(IntPtr IPDF, double PosX, double PosY, double Width, double Height, [MarshalAs(UnmanagedType.LPStr)] string Author, [MarshalAs(UnmanagedType.LPStr)] string AnnotName, [MarshalAs(UnmanagedType.LPStr)] string U3DFile, [MarshalAs(UnmanagedType.LPStr)] string ImageFile);
public static extern int pdfCreate3DAnnotW(IntPtr IPDF, double PosX, double PosY, double Width, double Height, [MarshalAs(UnmanagedType.LPWStr)] string Author, [MarshalAs(UnmanagedType.LPWStr)] string AnnotName, [MarshalAs(UnmanagedType.LPWStr)] string U3DFile, [MarshalAs(UnmanagedType.LPWStr)] string ImageFile);
Area
Annotations
Category

Object Creation

Exported names

pdfCreate3DAnnot pdfCreate3DAnnotA pdfCreate3DAnnotW

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.