Reference Guide
GdPicture14 Namespace / GdPicturePDF Class / AddStampAnnotation Method
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 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 width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The title of the newly added annotation object, by convention it represents the author of the annotation.
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.
A member of the PdfRubberStampAnnotationIcon enumeration. The name of an icon, means the appearance of a stamp, to be used when displaying the annotation.
The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
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.
Example





In This Topic
    AddStampAnnotation Method (GdPicturePDF)
    In This Topic
    Adds a rubber stamp annotation object on the currently selected page of the loaded PDF document. The subtype attribute of this annotation is "Stamp". This annotation displays text or graphics in the way as if they were stamped on the page according to the defined parameters. When it is opened, it displays a pop-up window with the content according to what you have specified.

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

    Syntax
    'Declaration
     
    
    Public Function AddStampAnnotation( _
       ByVal Left As Single, _
       ByVal Top As Single, _
       ByVal Width As Single, _
       ByVal Height As Single, _
       ByVal Title As String, _
       ByVal Contents As String, _
       ByVal StampStyle As PdfRubberStampAnnotationIcon, _
       ByVal Opacity As Single, _
       ByVal Red As Byte, _
       ByVal Green As Byte, _
       ByVal Blue As Byte _
    ) As Integer
    public int AddStampAnnotation( 
       float Left,
       float Top,
       float Width,
       float Height,
       string Title,
       string Contents,
       PdfRubberStampAnnotationIcon StampStyle,
       float Opacity,
       byte Red,
       byte Green,
       byte Blue
    )
    public function AddStampAnnotation( 
        Left: Single;
        Top: Single;
        Width: Single;
        Height: Single;
        Title: String;
        Contents: String;
        StampStyle: PdfRubberStampAnnotationIcon;
        Opacity: Single;
        Red: Byte;
        Green: Byte;
        Blue: Byte
    ): Integer; 
    public function AddStampAnnotation( 
       Left : float,
       Top : float,
       Width : float,
       Height : float,
       Title : String,
       Contents : String,
       StampStyle : PdfRubberStampAnnotationIcon,
       Opacity : float,
       Red : byte,
       Green : byte,
       Blue : byte
    ) : int;
    public: int AddStampAnnotation( 
       float Left,
       float Top,
       float Width,
       float Height,
       string* Title,
       string* Contents,
       PdfRubberStampAnnotationIcon StampStyle,
       float Opacity,
       byte Red,
       byte Green,
       byte Blue
    ) 
    public:
    int AddStampAnnotation( 
       float Left,
       float Top,
       float Width,
       float Height,
       String^ Title,
       String^ Contents,
       PdfRubberStampAnnotationIcon StampStyle,
       float Opacity,
       byte Red,
       byte Green,
       byte Blue
    ) 

    Parameters

    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 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.
    Width
    The width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
    Height
    The height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
    Title
    The title of the newly added annotation object, by convention it represents the author of the annotation.
    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.
    StampStyle
    A member of the PdfRubberStampAnnotationIcon enumeration. The name of an icon, means the appearance of a stamp, to be used when displaying the annotation.
    Opacity
    The opacity value of the newly added annotation object, from 0 (full transparency) to 1 (full opacity).
    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.

    Return Value

    The unique annotation index from 0 to GetAnnotationCount-1 related to the currently selected page. Please always use the GetStat method to determine if this method has been successful.
    Remarks
    Please note that this method is only allowed for use with non-encrypted documents.

    We strongly recommend using the GetStat method to identify the specific reason for the method's failure.

    Please always ensure that you have selected the correct page using the SelectPage method before adding a required annotation. Likewise, just to inform you, that the toolkit doesn't create (unlike other applications can) a standalone associated pop-up annotation object within the internal document structure when creating the new stamp annotation.

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

    Example
    How to create a green stamp annotation on a new page of the PDF document.
    Dim caption As String = "Example: AddStampAnnotation"
    Dim oGdPicturePDF As GdPicturePDF = New GdPicturePDF()
    If (oGdPicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
       (oGdPicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
        oGdPicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
        oGdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter)
        'Please always select the required page before adding an annotation.
        If oGdPicturePDF.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 = oGdPicturePDF.AddStampAnnotation(5, 10, 10, 7, "GdPicture", "This is a stamp annotation.",
                                                                      PdfRubberStampAnnotationIcon.Approved, 0.75F, 0, 255, 0)
            If oGdPicturePDF.GetStat() = GdPictureStatus.OK Then
                Dim annotType As String = oGdPicturePDF.GetAnnotationType(annotID)
                Dim status1 As GdPictureStatus = oGdPicturePDF.GetStat()
                Dim annotSubtype As String = oGdPicturePDF.GetAnnotationSubType(annotID)
                Dim status2 As GdPictureStatus = oGdPicturePDF.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 oGdPicturePDF.SaveToFile("stamp.pdf") = GdPictureStatus.OK Then
                    message = message + vbCrLf + "The file has been saved."
                Else
                    message = message + vbCrLf + "The file can't be saved. Status: " + oGdPicturePDF.GetStat().ToString()
                End If
                MessageBox.Show(message, caption)
            Else
                MessageBox.Show("The AddStampAnnotation() method has failed with the status: " + oGdPicturePDF.GetStat().ToString(), caption)
            End If
        Else
            MessageBox.Show("The SelectPage() method has failed with the status: " + oGdPicturePDF.GetStat().ToString(), caption)
        End If
    Else
        MessageBox.Show("The file can't be created.", caption)
    End If
    oGdPicturePDF.Dispose()
    string caption = "Example: AddStampAnnotation";
    GdPicturePDF oGdPicturePDF = new GdPicturePDF();
    if ((oGdPicturePDF.NewPDF() == GdPictureStatus.OK) &&
        (oGdPicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
    {
        oGdPicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
        oGdPicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitCentimeter);
        //Please always select the required page before adding an annotation.
        if (oGdPicturePDF.SelectPage(1) == GdPictureStatus.OK)
        {
            int annotID = oGdPicturePDF.AddStampAnnotation(5, 10, 10, 7, "GdPicture", "This is a stamp annotation.",
                                                           PdfRubberStampAnnotationIcon.Approved, 0.75f, 0, 255, 0);
            //Each valid annotID should be >= 0, but it is recommended to check the error status, not the returned ID.
            if (oGdPicturePDF.GetStat() == GdPictureStatus.OK)
            {
                string annotType = oGdPicturePDF.GetAnnotationType(annotID);
                GdPictureStatus status1 = oGdPicturePDF.GetStat();
                string annotSubtype = oGdPicturePDF.GetAnnotationSubType(annotID);
                GdPictureStatus status2 = oGdPicturePDF.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 (oGdPicturePDF.SaveToFile("stamp.pdf") == GdPictureStatus.OK)
                    message = message + "\nThe file has been saved.";
                else
                    message = message + "\nThe file can't be saved. Status: " + oGdPicturePDF.GetStat().ToString();
                MessageBox.Show(message, caption);
            }
            else
                MessageBox.Show("The AddStampAnnotation() method has failed with the status: " + oGdPicturePDF.GetStat().ToString(), caption);
        }
        else
            MessageBox.Show("The SelectPage() method has failed with the status: " + oGdPicturePDF.GetStat().ToString(), caption);
    }
    else
        MessageBox.Show("The file can't be created.", caption);
    oGdPicturePDF.Dispose();
    See Also