GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / AddStickyNoteAnnotation Method
A member of the PdfStickyNoteAnnotationIcon enumeration. The name of the icon to be used when displaying the annotation.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located. The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located. The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
The title of the newly added annotation object, by convention it represents the author of the annotation.
The subject of the newly added annotation object.
The content of the newly added annotation object, that means the text displayed in the annotation's note and in its associated pop-up window.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
A flag specifying whether the annotation should initially be displayed open, means whether the annotation's pop-up window should be opened. The initial value is false (closed).
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's pop-up window is to be located. The value is expressed in the currently set units according to the currently used coordinate space.
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's pop-up window is to be located. The value is expressed in the currently set units according to the currently used coordinate space.
The width of the annotation's pop-up window, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's pop-up window, expressed in the current units specified by the SetMeasurementUnit method.
Example





In This Topic
AddStickyNoteAnnotation Method (GdPicturePDF)
In This Topic
Adds a text annotation object, so called "sticky note" annotation, on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Text". When opened, it displays a pop-up window with text, when closed, it appears as an icon according to what you have specified.

This method uses the RGB color space for specifying the required (background) color of the annotation object.

Since each text annotation makes use of an associated pop-up window, adding a text annotation to your document includes at the same adding an annotation object, that represents this pop-up window. The subtype attribute of this annotation is "Popup" and therefore the resulting count of all annotations in your document increases by two. This pop-up annotation object is inscribed in the internal structure of the current document.

Syntax
'Declaration
 
Public Function AddStickyNoteAnnotation( _
   ByVal IconName As PdfStickyNoteAnnotationIcon, _
   ByVal Left As Single, _
   ByVal Top As Single, _
   ByVal Author As String, _
   ByVal Subject As String, _
   ByVal Contents As String, _
   ByVal Opacity As Single, _
   ByVal OpenPopup As Boolean, _
   ByVal Red As Byte, _
   ByVal Green As Byte, _
   ByVal Blue As Byte, _
   ByVal PopupLeft As Single, _
   ByVal PopupTop As Single, _
   ByVal PopupWidth As Single, _
   ByVal PopupHeight As Single _
) As Integer
public int AddStickyNoteAnnotation( 
   PdfStickyNoteAnnotationIcon IconName,
   float Left,
   float Top,
   string Author,
   string Subject,
   string Contents,
   float Opacity,
   bool OpenPopup,
   byte Red,
   byte Green,
   byte Blue,
   float PopupLeft,
   float PopupTop,
   float PopupWidth,
   float PopupHeight
)
public function AddStickyNoteAnnotation( 
    IconName: PdfStickyNoteAnnotationIcon;
    Left: Single;
    Top: Single;
    Author: String;
    Subject: String;
    Contents: String;
    Opacity: Single;
    OpenPopup: Boolean;
    Red: Byte;
    Green: Byte;
    Blue: Byte;
    PopupLeft: Single;
    PopupTop: Single;
    PopupWidth: Single;
    PopupHeight: Single
): Integer; 
public function AddStickyNoteAnnotation( 
   IconName : PdfStickyNoteAnnotationIcon,
   Left : float,
   Top : float,
   Author : String,
   Subject : String,
   Contents : String,
   Opacity : float,
   OpenPopup : boolean,
   Red : byte,
   Green : byte,
   Blue : byte,
   PopupLeft : float,
   PopupTop : float,
   PopupWidth : float,
   PopupHeight : float
) : int;
public: int AddStickyNoteAnnotation( 
   PdfStickyNoteAnnotationIcon IconName,
   float Left,
   float Top,
   string* Author,
   string* Subject,
   string* Contents,
   float Opacity,
   bool OpenPopup,
   byte Red,
   byte Green,
   byte Blue,
   float PopupLeft,
   float PopupTop,
   float PopupWidth,
   float PopupHeight
) 
public:
int AddStickyNoteAnnotation( 
   PdfStickyNoteAnnotationIcon IconName,
   float Left,
   float Top,
   String^ Author,
   String^ Subject,
   String^ Contents,
   float Opacity,
   bool OpenPopup,
   byte Red,
   byte Green,
   byte Blue,
   float PopupLeft,
   float PopupTop,
   float PopupWidth,
   float PopupHeight
) 

Parameters

IconName
A member of the PdfStickyNoteAnnotationIcon enumeration. The name of the icon to be used when displaying the annotation.
Left
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located. The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
Top
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's bounding box is to be located. The value is expressed in the current units specified by the SetMeasurementUnit method and it is related to the current page. For further assistance, please see the Remarks section below.
Author
The title of the newly added annotation object, by convention it represents the author of the annotation.
Subject
The subject of the newly added annotation object.
Contents
The content of the newly added annotation object, that means the text displayed in the annotation's note and in its associated pop-up window.
Opacity
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
OpenPopup
A flag specifying whether the annotation should initially be displayed open, means whether the annotation's pop-up window should be opened. The initial value is false (closed).
Red
The amount of red color to be used for the resulting color. Use the value between 0 and 255.
Green
The amount of green color to be used for the resulting color. Use the value between 0 and 255.
Blue
The amount of blue color to be used for the resulting color. Use the value between 0 and 255.
PopupLeft
The horizontal (X) coordinate of the closest point to the currently defined origin, where the annotation's pop-up window is to be located. The value is expressed in the currently set units according to the currently used coordinate space.
PopupTop
The vertical (Y) coordinate of the closest point to the currently defined origin, where the annotation's pop-up window is to be located. The value is expressed in the currently set units according to the currently used coordinate space.
PopupWidth
The width of the annotation's pop-up window, expressed in the current units specified by the SetMeasurementUnit method.
PopupHeight
The height of the annotation's pop-up window, expressed in the current units specified by the SetMeasurementUnit method.

Return Value

The unique annotation index (of the added annotation object of the subtype "Text") from 0 to GdPicturePDF.GetAnnotationCount-1 related to the currently selected page. The GdPicturePDF.GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GdPicturePDF.GetStat method to identify the specific reason for the method's failure, if any.

Please always ensure that you have selected the correct page using the GdPicturePDF.SelectPage method before adding a required annotation. Likewise, just to remind you that adding a text annotation increases the resulting count of all annotations in your document by two, as it is described above.

You also need to be aware that the values of coordinates and dimensions are expressed in the current units defined by the GdPicturePDF.SetMeasurementUnit method according to the current coordinate space defined by the GdPicturePDF.SetOrigin method.

Example
How to create a yellow sticky note annotation on a new page of the PDF document.
Dim caption As String = "Example: AddStickyNoteAnnotation"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
   (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
    'Please always select the required page before adding an annotation.
    If gdpicturePDF.SelectPage(1) = GdPictureStatus.OK Then
        'Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
        Dim annotID As Integer = gdpicturePDF.AddStickyNoteAnnotation(PdfStickyNoteAnnotationIcon.PdfAnnotationIconComment, 5, 5,
                                                                       "GdPicture", "Important note!", "This is a sticky note annotation.",
                                                                       0.75F, True, 255, 255, 0, 15, 5, 10, 10)
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            Dim annotType As String = gdpicturePDF.GetAnnotationType(annotID)
            Dim status1 As GdPictureStatus = gdpicturePDF.GetStat()
            Dim annotSubtype As String = gdpicturePDF.GetAnnotationSubType(annotID)
            Dim status2 As GdPictureStatus = gdpicturePDF.GetStat()
            Dim message As String = "The annotation has been created with the ID = " + annotID.ToString() + "." + vbCrLf + "type: "
            If status1 = GdPictureStatus.OK Then message = message + annotType Else message = message + status1.ToString()
            message = message + "    subtype: "
            If status2 = GdPictureStatus.OK Then message = message + annotSubtype Else message = message + status2.ToString()
            If gdpicturePDF.SaveToFile("stickynote.pdf") = GdPictureStatus.OK Then
                message = message + vbCrLf + "The file has been saved."
            Else
                message = message + vbCrLf + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
            End If
            MessageBox.Show(message, caption)
        Else
            MessageBox.Show("The AddStickyNoteAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
        End If
    Else
        MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: AddStickyNoteAnnotation";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
    (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
    gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
    gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
    //Please always select the required page before adding an annotation.
    if (gdpicturePDF.SelectPage(1) == GdPictureStatus.OK)
    {
        int annotID = gdpicturePDF.AddStickyNoteAnnotation(PdfStickyNoteAnnotationIcon.PdfAnnotationIconComment,
                                                            5, 5, "GdPicture", "Important note!", "This is a sticky note annotation.",
                                                            0.75f, true, 255, 255, 0, 15, 5, 10, 10);
        //Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
        {
            string annotType = gdpicturePDF.GetAnnotationType(annotID);
            GdPictureStatus status1 = gdpicturePDF.GetStat();
            string annotSubtype = gdpicturePDF.GetAnnotationSubType(annotID);
            GdPictureStatus status2 = gdpicturePDF.GetStat();
            string message = "The annotation has been created with the ID = " + annotID.ToString() + ".\ntype: ";
            if (status1 == GdPictureStatus.OK) message = message + annotType; else message = message + status1.ToString();
            message = message + "    subtype: ";
            if (status2 == GdPictureStatus.OK) message = message + annotSubtype; else message = message + status2.ToString();
            if (gdpicturePDF.SaveToFile("stickynote.pdf") == GdPictureStatus.OK)
                message = message + "\nThe file has been saved.";
            else
                message = message + "\nThe file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
            MessageBox.Show(message, caption);
        }
        else
            MessageBox.Show("The AddStickyNoteAnnotation() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
    }
    else
        MessageBox.Show("The SelectPage() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
    MessageBox.Show("The file can't be created.", caption);
gdpicturePDF.Dispose();
See Also