GdPicture.NET.14
GdPicture14 Namespace / AnnotationManager Class / AddEmbeddedImageAnnot Method / AddEmbeddedImageAnnot(Int32,Single,Single,Single,Single) Method
A unique image identifier of the GdPictureImage object representing the required image to render as an annotation. You can obtain this identifier, for example, using methods of the GdPictureImaging class when creating the image resource.
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
The width of the annotation bounding box, in inches.
The height of the annotation bounding box, in inches.
Example





In This Topic
AddEmbeddedImageAnnot(Int32,Single,Single,Single,Single) Method
In This Topic
Adds a new GdPicture/XMP embedded image annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified. This annotation embeds the specified image on the page within the defined rectangle area.

The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeEmbeddedImage. You can change the annotation properties directly using the GdPicture14.Annotations.AnnotationEmbeddedImage class right after the successful creation of the annotation object.

Be aware that annotations are always treated relative to the currently selected page.

Syntax
'Declaration
 
Public Overloads Function AddEmbeddedImageAnnot( _
   ByVal ImageID As Integer, _
   ByVal Left As Single, _
   ByVal Top As Single, _
   ByVal Width As Single, _
   ByVal Height As Single _
) As AnnotationEmbeddedImage
public AnnotationEmbeddedImage AddEmbeddedImageAnnot( 
   int ImageID,
   float Left,
   float Top,
   float Width,
   float Height
)
public function AddEmbeddedImageAnnot( 
    ImageID: Integer;
    Left: Single;
    Top: Single;
    Width: Single;
    Height: Single
): AnnotationEmbeddedImage; 
public function AddEmbeddedImageAnnot( 
   ImageID : int,
   Left : float,
   Top : float,
   Width : float,
   Height : float
) : AnnotationEmbeddedImage;
public: AnnotationEmbeddedImage* AddEmbeddedImageAnnot( 
   int ImageID,
   float Left,
   float Top,
   float Width,
   float Height
) 
public:
AnnotationEmbeddedImage^ AddEmbeddedImageAnnot( 
   int ImageID,
   float Left,
   float Top,
   float Width,
   float Height
) 

Parameters

ImageID
A unique image identifier of the GdPictureImage object representing the required image to render as an annotation. You can obtain this identifier, for example, using methods of the GdPictureImaging class when creating the image resource.
Left
The horizontal (X) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
Top
The vertical (Y) coordinate of the top left point, in inches, where the annotation bounding box is to be located.
Width
The width of the annotation bounding box, in inches.
Height
The height of the annotation bounding box, in inches.

Return Value

A GdPicture/XMP AnnotationEmbeddedImage object. The newly added GdPicture/XMP embedded image annotation.
Remarks
Please ensure that you have selected the proper page before starting any annotation related action with the handled document. Annotations are always treated relative to the currently selected page.

You can regularly apply the GetStat method to determine if this method has been successful.

Example
How to add an embedded image annotation on the currently selected page of the handled document.
Using annotMgr As AnnotationManager = New AnnotationManager()
    If (annotMgr.InitFromFile("source.jpeg") = GdPictureStatus.OK) AndAlso
       (annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
        Using image As GdPictureImaging = New GdPictureImaging()
            Dim imageID As Integer = image.CreateGdPictureImageFromFile("annotation.jpeg")
            If image.GetStat() = GdPictureStatus.OK Then
                Dim annot As GdPicture14.Annotations.AnnotationEmbeddedImage = annotMgr.AddEmbeddedImageAnnot(imageID, 0.5F, 0.5F, 2, 3)
                If (annotMgr.GetStat() = GdPictureStatus.OK) AndAlso (annot IsNot Nothing) Then
                    annot.Author = "GdPicture"
                    annot.Opacity = 0.8F
                    If annotMgr.SaveAnnotationsToPage() = GdPictureStatus.OK Then
                        annotMgr.SaveDocumentToJPEG("dest.jpeg", 80)
                    End If
                End If
                annot.Dispose()
                image.ReleaseGdPictureImage(imageID)
            Else
                MessageBox.Show("Error!   Status: " + image.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot")
            End If
        End Using
    End If
    If annotMgr.GetStat() = GdPictureStatus.OK Then
        MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnot")
    Else
        MessageBox.Show("Error!   Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot")
    End If
    annotMgr.Close()
End Using
using (AnnotationManager annotMgr = new AnnotationManager())
{
    if ((annotMgr.InitFromFile("source.jpeg") == GdPictureStatus.OK) &&
        (annotMgr.SelectPage(1) == GdPictureStatus.OK))
    {
        using (GdPictureImaging image = new GdPictureImaging())
        {
            int imageID = image.CreateGdPictureImageFromFile("annotation.jpeg");
            if (image.GetStat() == GdPictureStatus.OK)
            {
                GdPicture14.Annotations.AnnotationEmbeddedImage annot = annotMgr.AddEmbeddedImageAnnot(imageID, 0.5f, 0.5f, 2, 3);
                if ((annotMgr.GetStat() == GdPictureStatus.OK) && (annot != null))
                {
                    annot.Author = "GdPicture";
                    annot.Opacity = 0.8f;
                    if (annotMgr.SaveAnnotationsToPage() == GdPictureStatus.OK)
                        annotMgr.SaveDocumentToJPEG("dest.jpeg", 80);
                }
                annot.Dispose();
                image.ReleaseGdPictureImage(imageID);
            }
            else
                MessageBox.Show("Error!   Status: " + image.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot");
        }
    }
    if (annotMgr.GetStat() == GdPictureStatus.OK)
        MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnot");
    else
        MessageBox.Show("Error!   Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnot");
    annotMgr.Close();
}
See Also