AddImageFromHandle
IPDFDocument4 :: Images

See Also Example
Collapse All

This method adds an image from a handle into a PDF document's images collection and returns the index of the added image.

Syntax

LONG AddImageFromHandle (
OLE_HANDLE handle
)
Parameters
handle
Handle to an image object

Return value
Index of the new image

Remarks

The return value is an image identifier in the document's images collection and can be used in GetImageHeight, GetImageResolution, GetImageWidth, TransformImage, ShowImage, DrawImage.

Example

Adding an Image from a Handle

Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
{ OLE_HANDLE hImage is containing an image data }
ind := PDF.AddImageFromHandle(hImage);
PDF.ShowImage(ind, 0, 0);
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
// OLE_HANDLE hImage is containing an image data
long ind = PDF->AddImageFromHandle(hImage);
PDF->ShowImage(ind, 0, 0);
PDF->SaveToFile("test.pdf", true);
C#
[copy to clipboard]
// PDF object is supposed to be created
// Image img is an image loaded before.

// get a handle for this picture
Bitmap b = (Bitmap)img;
IntPtr handle = b.GetHbitmap();
int h = handle.ToInt32();

// now load the picture into PDF
int imgId = pdf.AddImageFromHandle(h);
pdf.ShowImage(imgId, 1, 1);

long ind = PDF.AddImageFromHandle(hImage);
PDF.ShowImage(ind, 0, 0);
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
' OLE_HANDLE hImage is containing an image data
ind = PDF.AddImageFromHandle(hImage)
PDF.ShowImage ind, 0, 0
PDF.SaveToFile "test.pdf", true

See Also

Reference