The 0-based index of the required annotation within the current page. It must be a value from 0 to GetAnnotationCount-1.
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 new width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
The new height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / SetAnnotationRect Method

SetAnnotationRect Method (GdPicturePDF)

In This Topic
Sets the rectangle (the bounding box) of a required annotation object specified by its index related to the currently selected page of the loaded PDF document. This rectangle defines the location of the annotation on the page expressed in the current units used in this document with respect to the currently defined origin. You can use the SetMeasurementUnit method to reset the units and the SetOrigin method to reset the origin's location according to your preference.
Syntax
'Declaration
 
Public Function SetAnnotationRect( _
   ByVal AnnotationIdx As Integer, _
   ByVal Left As Single, _
   ByVal Top As Single, _
   ByVal Width As Single, _
   ByVal Height As Single _
) As GdPictureStatus
public GdPictureStatus SetAnnotationRect( 
   int AnnotationIdx,
   float Left,
   float Top,
   float Width,
   float Height
)
public function SetAnnotationRect( 
    AnnotationIdx: Integer;
    Left: Single;
    Top: Single;
    Width: Single;
    Height: Single
): GdPictureStatus; 
public function SetAnnotationRect( 
   AnnotationIdx : int,
   Left : float,
   Top : float,
   Width : float,
   Height : float
) : GdPictureStatus;
public: GdPictureStatus SetAnnotationRect( 
   int AnnotationIdx,
   float Left,
   float Top,
   float Width,
   float Height
) 
public:
GdPictureStatus SetAnnotationRect( 
   int AnnotationIdx,
   float Left,
   float Top,
   float Width,
   float Height
) 

Parameters

AnnotationIdx
The 0-based index of the required annotation within the current page. It must be a value from 0 to GetAnnotationCount-1.
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.
Width
The new width of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.
Height
The new height of the annotation's bounding box, expressed in the current units specified by the SetMeasurementUnit method.

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.

Likewise always ensure that you have selected the correct page using the SelectPage method before applying an annotation index.

Be aware that the values of the 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 change (to double in this example) the bounding box of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationRect"
Dim gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
    Dim pageCount As Integer = gdpicturePDF.GetPageCount()
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        Dim message As String = ""
        Dim status As GdPictureStatus = GdPictureStatus.OK
        For page As Integer = 1 To pageCount
            message = message + "Page nr." + page.ToString()
            status = gdpicturePDF.SelectPage(page)
            If status = GdPictureStatus.OK Then
                Dim annotCount As Integer = gdpicturePDF.GetAnnotationCount()
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    message = message + "  Annots: " + annotCount.ToString()
                    Dim l As Single = 0, t As Single = 0, w As Single = 0, h As Single = 0
                    For annotID As Integer = 0 To annotCount - 1
                        status = gdpicturePDF.GetAnnotationRect(annotID, l, t, w, h)
                        If status = GdPictureStatus.OK Then
                            status = gdpicturePDF.SetAnnotationRect(annotID, l, t, 2 * w, 2 * h)
                        End If
                        If status <> GdPictureStatus.OK Then Exit For
                    Next
                    message = message + "  status: " + status.ToString()
                Else
                    message = message + "GetAnnotationCount - status: " + status.ToString()
                End If
            Else
                message = message + "SelectPage - status: " + status.ToString()
            End If
            message += vbCrLf
        Next
        If gdpicturePDF.SaveToFile("test_rectangle.pdf") = GdPictureStatus.OK Then
            message = message + "The file has been saved."
        Else
            message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString()
        End If
        MessageBox.Show(message, caption)
    Else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetAnnotationRect";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
    int pageCount = gdpicturePDF.GetPageCount();
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        string message = "";
        GdPictureStatus status = GdPictureStatus.OK;
        for (int page = 1; page <= pageCount; page++)
        {
            message = message + "Page nr." + page.ToString();
            status = gdpicturePDF.SelectPage(page);
            if (status == GdPictureStatus.OK)
            {
                int annotCount = gdpicturePDF.GetAnnotationCount();
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                {
                    message = message + "  Annots: " + annotCount.ToString();
                    float l = 0, t = 0, w = 0, h = 0;
                    for (int annotID = 0; annotID < annotCount; annotID++)
                    {
                        status = gdpicturePDF.GetAnnotationRect(annotID, ref l, ref t, ref w, ref h);
                        if (status == GdPictureStatus.OK)
                            status = gdpicturePDF.SetAnnotationRect(annotID, l, t, 2*w, 2*h);
                        if (status != GdPictureStatus.OK) break;
                    }
                    message = message + "  status: " + status.ToString();
                }
                else
                    message = message + "GetAnnotationCount - status: " + status.ToString();
            }
            else
                message = message + "SelectPage - status: " + status.ToString();
            message += "\n";
        }
        if (gdpicturePDF.SaveToFile("test_rectangle.pdf") == GdPictureStatus.OK)
            message = message + "The file has been saved.";
        else
            message = message + "The file can't be saved. Status: " + gdpicturePDF.GetStat().ToString();
        MessageBox.Show(message, caption);
    }
    else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
    MessageBox.Show("The file can't be loaded.", caption);
gdpicturePDF.Dispose();
See Also