GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / SetBookmarkColor Method / SetBookmarkColor(Int32,Byte,Byte,Byte,Byte) Method
A unique bookmark identifier specifying a required bookmark object.

You can obtain this identifier using these methods: NewBookmark, GetBookmarkRootID, GetBookmarkFirstChildID, GetBookmarkNextID, GetBookmarkPrevID or GetBookmarkParentID.

The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
The amount of magenta to be used for the resulting color. Use the value between 0 and 255.
The amount of yellow to be used for the resulting color. Use the value between 0 and 255.
The amount of black (key) color to be used for the resulting color. Use the value between 0 and 255.
Example





In This Topic
SetBookmarkColor(Int32,Byte,Byte,Byte,Byte) Method
In This Topic
Sets the color to be used for displaying the bookmark's title of a bookmark item specified by its unique identifier.

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

Syntax
'Declaration
 
Public Overloads Function SetBookmarkColor( _
   ByVal BookmarkID As Integer, _
   ByVal Cyan As Byte, _
   ByVal Magenta As Byte, _
   ByVal Yellow As Byte, _
   ByVal Black As Byte _
) As GdPictureStatus
public GdPictureStatus SetBookmarkColor( 
   int BookmarkID,
   byte Cyan,
   byte Magenta,
   byte Yellow,
   byte Black
)
public function SetBookmarkColor( 
    BookmarkID: Integer;
    Cyan: Byte;
    Magenta: Byte;
    Yellow: Byte;
    Black: Byte
): GdPictureStatus; 
public function SetBookmarkColor( 
   BookmarkID : int,
   Cyan : byte,
   Magenta : byte,
   Yellow : byte,
   Black : byte
) : GdPictureStatus;
public: GdPictureStatus SetBookmarkColor( 
   int BookmarkID,
   byte Cyan,
   byte Magenta,
   byte Yellow,
   byte Black
) 
public:
GdPictureStatus SetBookmarkColor( 
   int BookmarkID,
   byte Cyan,
   byte Magenta,
   byte Yellow,
   byte Black
) 

Parameters

BookmarkID
A unique bookmark identifier specifying a required bookmark object.

You can obtain this identifier using these methods: NewBookmark, GetBookmarkRootID, GetBookmarkFirstChildID, GetBookmarkNextID, GetBookmarkPrevID or GetBookmarkParentID.

Cyan
The amount of cyan color to be used for the resulting color. Use the value between 0 and 255.
Magenta
The amount of magenta to be used for the resulting color. Use the value between 0 and 255.
Yellow
The amount of yellow to be used for the resulting color. Use the value between 0 and 255.
Black
The amount of black (key) color to be used for the resulting 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.
Example
How to set the cyan color (to be used for displaying the bookmark's title) to all bookmark items on the first level of the bookmark's hierarchy in the PDF document.
Dim caption As String = "Example: SetBookmarkColor"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("bookmarks.pdf", False)
If status = GdPictureStatus.OK Then
    Dim bookmarkID As Integer = gdpicturePDF.GetBookmarkRootID()
    status = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        While status = GdPictureStatus.OK
            status = gdpicturePDF.SetBookmarkColor(bookmarkID, 255, 0, 0, 0)
            If status = GdPictureStatus.OK Then
                bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID)
                status = gdpicturePDF.GetStat()
            End If
        End While
        If status = GdPictureStatus.PropertyNotFound Then
            status = gdpicturePDF.SaveToFile("bookmarks_SetColor.pdf")
            If status = GdPictureStatus.OK Then
                MessageBox.Show("The example HAS been followed successfully.", caption)
            Else
                MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
            End If
        Else
            MessageBox.Show("The example HAS NOT been followed successfully." + vbCrLf + "The error status is: " + status, caption)
        End If
    Else
        If status = GdPictureStatus.PropertyNotFound Then
            MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption)
        Else
            MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption)
        End If
    End If
Else
    MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: SetBookmarkColor";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("bookmarks.pdf", false);
if (status == GdPictureStatus.OK)
{
    int bookmarkID = gdpicturePDF.GetBookmarkRootID();
    status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        while (status == GdPictureStatus.OK)
        {
            status = gdpicturePDF.SetBookmarkColor(bookmarkID, 255, 0, 0, 0);
            if (status == GdPictureStatus.OK)
            {
                bookmarkID = gdpicturePDF.GetBookmarkNextID(bookmarkID);
                status = gdpicturePDF.GetStat();
            }
        }
        if (status == GdPictureStatus.PropertyNotFound)
        {
            status = gdpicturePDF.SaveToFile("bookmarks_SetColor.pdf");
            if (status == GdPictureStatus.OK)
                MessageBox.Show("The example HAS been followed successfully.", caption);
            else
                MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
        }
        else
            MessageBox.Show("The example HAS NOT been followed successfully.\nThe error status is: " + status, caption);
    }
    else
    {
        if (status == GdPictureStatus.PropertyNotFound)
            MessageBox.Show("This PDF document doesn't contain any bookmarks.", caption);
        else
            MessageBox.Show("The GetBookmarkRootID() method has failed with the status: " + status.ToString(), caption);
    }
}
else
{
    MessageBox.Show("The file can't be loaded. Status: " + status.ToString(), caption);
}
gdpicturePDF.Dispose();
See Also