AddEmbeddedImageAnnotFromBase64 Method (AnnotationManager)
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 image from a bitmap file stored in base64 string 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 Function AddEmbeddedImageAnnotFromBase64( _
ByVal As String, _
ByVal As Single, _
ByVal As Single, _
ByVal As Single, _
ByVal As Single _
) As AnnotationEmbeddedImage
public AnnotationEmbeddedImage AddEmbeddedImageAnnotFromBase64(
string ,
float ,
float ,
float ,
float
)
public function AddEmbeddedImageAnnotFromBase64(
: String;
: Single;
: Single;
: Single;
: Single
): AnnotationEmbeddedImage;
public function AddEmbeddedImageAnnotFromBase64(
: String,
: float,
: float,
: float,
: float
) : AnnotationEmbeddedImage;
public: AnnotationEmbeddedImage* AddEmbeddedImageAnnotFromBase64(
string* ,
float ,
float ,
float ,
float
)
public:
AnnotationEmbeddedImage^ AddEmbeddedImageAnnotFromBase64(
String^ ,
float ,
float ,
float ,
float
)
Parameters
- Base64Image
- A base64 encoded string containing the data of the image to render as an annotation.
- 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.
Example
How to add an embedded image annotation from the string on the currently selected page of the handled document.
Using annotMgr As AnnotationManager = New AnnotationManager()
'We assume you have an image resource in a Base64 string here.
Dim image As String = "Your image in Base64 encoded string"
If (annotMgr.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim annot As GdPicture14.Annotations.AnnotationEmbeddedImage = annotMgr.AddEmbeddedImageAnnotFromBase64(image, 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.SaveDocumentToPDF("dest.pdf")
End If
annot.Dispose()
End If
If annotMgr.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnotFromBase64")
Else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnotFromBase64")
End If
annotMgr.Close()
End Using
using (AnnotationManager annotMgr = new AnnotationManager())
{
//We assume you have an image resource in a Base64 string here.
string image = "Your image in Base64 encoded string";
if ((annotMgr.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationEmbeddedImage annot = annotMgr.AddEmbeddedImageAnnotFromBase64(image, 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.SaveDocumentToPDF("dest.pdf");
}
annot.Dispose();
}
if (annotMgr.GetStat() == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnotFromBase64");
else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnotFromBase64");
annotMgr.Close();
}
Example
How to add an embedded image annotation from the string on the currently selected page of the handled document.
Using annotMgr As AnnotationManager = New AnnotationManager()
'We assume you have an image resource in a Base64 string here.
Dim image As String = "Your image in Base64 encoded string"
If (annotMgr.InitFromFile("source.pdf") = GdPictureStatus.OK) AndAlso
(annotMgr.SelectPage(1) = GdPictureStatus.OK) Then
Dim annot As GdPicture14.Annotations.AnnotationEmbeddedImage = annotMgr.AddEmbeddedImageAnnotFromBase64(image, 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.SaveDocumentToPDF("dest.pdf")
End If
annot.Dispose()
End If
If annotMgr.GetStat() = GdPictureStatus.OK Then
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnotFromBase64")
Else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnotFromBase64")
End If
annotMgr.Close()
End Using
using (AnnotationManager annotMgr = new AnnotationManager())
{
//We assume you have an image resource in a Base64 string here.
string image = "Your image in Base64 encoded string";
if ((annotMgr.InitFromFile("source.pdf") == GdPictureStatus.OK) &&
(annotMgr.SelectPage(1) == GdPictureStatus.OK))
{
GdPicture14.Annotations.AnnotationEmbeddedImage annot = annotMgr.AddEmbeddedImageAnnotFromBase64(image, 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.SaveDocumentToPDF("dest.pdf");
}
annot.Dispose();
}
if (annotMgr.GetStat() == GdPictureStatus.OK)
MessageBox.Show("Done!", "AnnotationManager.AddEmbeddedImageAnnotFromBase64");
else
MessageBox.Show("Error! Status: " + annotMgr.GetStat().ToString(), "AnnotationManager.AddEmbeddedImageAnnotFromBase64");
annotMgr.Close();
}
See Also