GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / SetAnnotationFillColor Method / SetAnnotationFillColor(Int32,Byte,Byte,Byte) Method
The 0-based index of the required annotation within the current page. It must be a value from 0 to GdPicturePDF.GetAnnotationCount-1.
The amount of red color to be used for the resulting interior color. Use the value between 0 and 255.
The amount of green color to be used for the resulting interior color. Use the value between 0 and 255.
The amount of blue color to be used for the resulting interior color. Use the value between 0 and 255.
Example





In This Topic
SetAnnotationFillColor(Int32,Byte,Byte,Byte) Method
In This Topic
Sets the interior color of a required annotation object specified by its index related to the currently selected page of the loaded PDF document.

This color is used for the following purposes:

  • To specify the interior color with which to fill the annotation’s rectangle or ellipse (for Square or Circle annotation types).
  • To specify the interior color with which to fill the annotation’s line endings (for Line, Polygon or PolyLine annotation types).

This method uses the RGB color space for specifying the required color.

Syntax
'Declaration
 
Public Overloads Function SetAnnotationFillColor( _
   ByVal AnnotationIdx As Integer, _
   ByVal Red As Byte, _
   ByVal Green As Byte, _
   ByVal Blue As Byte _
) As GdPictureStatus
public GdPictureStatus SetAnnotationFillColor( 
   int AnnotationIdx,
   byte Red,
   byte Green,
   byte Blue
)
public function SetAnnotationFillColor( 
    AnnotationIdx: Integer;
    Red: Byte;
    Green: Byte;
    Blue: Byte
): GdPictureStatus; 
public function SetAnnotationFillColor( 
   AnnotationIdx : int,
   Red : byte,
   Green : byte,
   Blue : byte
) : GdPictureStatus;
public: GdPictureStatus SetAnnotationFillColor( 
   int AnnotationIdx,
   byte Red,
   byte Green,
   byte Blue
) 
public:
GdPictureStatus SetAnnotationFillColor( 
   int AnnotationIdx,
   byte Red,
   byte Green,
   byte Blue
) 

Parameters

AnnotationIdx
The 0-based index of the required annotation within the current page. It must be a value from 0 to GdPicturePDF.GetAnnotationCount-1.
Red
The amount of red color to be used for the resulting interior color. Use the value between 0 and 255.
Green
The amount of green color to be used for the resulting interior color. Use the value between 0 and 255.
Blue
The amount of blue color to be used for the resulting interior color. Use the value between 0 and 255.

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 GdPicturePDF.SelectPage method before applying an annotation index.

Example
How to change the fill (interior) color of all annotations in the loaded PDF document.
Dim caption As String = "Example: SetAnnotationFillColor"
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()
                    For annotID As Integer = 0 To annotCount - 1
                        status = gdpicturePDF.SetAnnotationFillColor(annotID, 255, 69, 0)
                        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_fillcolor.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: SetAnnotationFillColor";
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();
                    for (int annotID = 0; annotID < annotCount; annotID++)
                    {
                        status = gdpicturePDF.SetAnnotationFillColor(annotID, 255, 69, 0);
                        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_fillcolor.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