GdPicture.NET.14
GdPicture14 Namespace / AnnotationManager Class / AddCustomAnnot Method
A private identifier specifying the model of the custom annotation. You need to handle this identifier using the OnCustomAnnotationPaint event to render the desired custom annotation appearance.
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
AddCustomAnnot Method (AnnotationManager)
In This Topic
Adds a new GdPicture/XMP custom annotation on the selected page of the document currently handled by this AnnotationManager object according to the parameters you have specified.

Custom annotations are identified through the ModelID identifier, which you subsequently have to use in the OnCustomAnnotationPaint event. This event renders the required annotation according to what you specify for each ModelID inside the event respecting the defined dimensions.

The type of the newly added annotation object is GdPictureAnnotationType.AnnotationTypeCustom. You can change the annotation properties directly using the GdPicture14.Annotations.AnnotationCustom 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 AddCustomAnnot( _
   ByVal ModelID As Integer, _
   ByVal Left As Single, _
   ByVal Top As Single, _
   ByVal Width As Single, _
   ByVal Height As Single _
) As AnnotationCustom
public AnnotationCustom AddCustomAnnot( 
   int ModelID,
   float Left,
   float Top,
   float Width,
   float Height
)
public function AddCustomAnnot( 
    ModelID: Integer;
    Left: Single;
    Top: Single;
    Width: Single;
    Height: Single
): AnnotationCustom; 
public function AddCustomAnnot( 
   ModelID : int,
   Left : float,
   Top : float,
   Width : float,
   Height : float
) : AnnotationCustom;
public: AnnotationCustom* AddCustomAnnot( 
   int ModelID,
   float Left,
   float Top,
   float Width,
   float Height
) 
public:
AnnotationCustom^ AddCustomAnnot( 
   int ModelID,
   float Left,
   float Top,
   float Width,
   float Height
) 

Parameters

ModelID
A private identifier specifying the model of the custom annotation. You need to handle this identifier using the OnCustomAnnotationPaint event to render the desired custom annotation appearance.
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 AnnotationCustom object. The newly added GdPicture/XMP custom 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.

You can also find the use of this method in our Annotations Sample here.

Just to inform you that custom annotations are not supported by the COM Interop edition.

Example
How to add custom annotations to your document.
'We assume that the GdViewer control has been integrated into your application.
If GdViewer1.DisplayFromFile("custom.pdf") = GdPictureStatus.OK Then
    'We assume that the annotationManager object has been integrated into your application as well,
    'together with the proper definition of annotationManager_OnCustomAnnotationPaint() event.
    annotationManager = GdViewer1.GetAnnotationManager();
    If (annotationManager.PageCount > 0) AndAlso (annotationManager.SelectPage(1) = GdPictureStatus.OK) Then
        Dim modelsCount As Integer = 2
        Dim x As Single = 1, y As Single = 1, w As Single = 1, h As Single = 1, dist As Single = 2
        For modelID As Integer = 1 To modelsCount
            Dim annot As GdPicture14.Annotations.AnnotationCustom = annotationManager.AddCustomAnnot(modelID, x, y + (modelID - 1) * dist, w, h)
            If annot IsNot Nothing Then
                annot.Tag = "GdPicture custom annotation"
            End If
        Next
        'The BurnAnnotationsToPage() method renders your custom anotations on the page using the annotationManager_OnCustomAnnotationPaint() event.
        If (annotationManager.SaveAnnotationsToPage() = GdPictureStatus.OK) AndAlso
           (annotationManager.BurnAnnotationsToPage(True, False) = GdPictureStatus.OK) AndAlso
           (annotationManager.SaveDocumentToPDF("custom.pdf") = GdPictureStatus.OK) Then
            'You also need to implement the GdViewer1_OnCustomAnnotationPaint() event, in the same way,
            'to be able to see the added custom annotations in the viewer.
            GdViewer1.Refresh()
        End If
    End If
    If annotationManager.GetStat() <> GdPictureStatus.OK Then
        MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddCustomAnnot")
    End If
Else
    MessageBox.Show("Error!   Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddCustomAnnot")
End If
//We assume that the GdViewer control has been integrated into your application.
if (GdViewer1.DisplayFromFile("custom.pdf") == GdPictureStatus.OK)
{
    //We assume that the annotationManager object has been integrated into your application as well,
    //together with the proper definition of annotationManager_OnCustomAnnotationPaint() event.
    annotationManager = GdViewer1.GetAnnotationManager();
    if ((annotationManager.PageCount > 0) && (annotationManager.SelectPage(1) == GdPictureStatus.OK))
    {
        int modelsCount = 2;
        float x = 1, y = 1, w = 1, h = 1, dist = 2;
        for (int modelID = 1; modelID <= modelsCount; modelID++)
        {
            GdPicture14.Annotations.AnnotationCustom annot = annotationManager.AddCustomAnnot(modelID, x, y+(modelID-1)*dist, w, h);
            if (annot != null)
            {
                annot.Tag = "GdPicture custom annotation";
            }
        }
        //The BurnAnnotationsToPage() method renders your custom anotations on the page using the annotationManager_OnCustomAnnotationPaint() event.
        if ((annotationManager.SaveAnnotationsToPage() == GdPictureStatus.OK) &&
            (annotationManager.BurnAnnotationsToPage(true, false) == GdPictureStatus.OK) &&
            (annotationManager.SaveDocumentToPDF("custom.pdf") == GdPictureStatus.OK))
        {
            //You also need to implement the GdViewer1_OnCustomAnnotationPaint() event, in the same way,
            //to be able to see the added custom annotations in the viewer.
            GdViewer1.Refresh();
        }
    }
    if (annotationManager.GetStat() != GdPictureStatus.OK)
        MessageBox.Show("Error!   Status: " + annotationManager.GetStat().ToString(), "AnnotationManager.AddCustomAnnot");
}
else
    MessageBox.Show("Error!   Status: " + GdViewer1.GetStat().ToString(), "AnnotationManager.AddCustomAnnot");
See Also