The unique identifier of the required OCG entry. You can obtain this identifier using the GetOCG method.
The new title to be used for the specified optional content group.
Example





In This Topic

SetOCGTitle Method (GdPicturePDF)

In This Topic
Sets up the title of an optional content group, in other words the name of a layer, specified by its unique identifier. This name is presented in the viewer's user interface.
Syntax
'Declaration

 

Public Function SetOCGTitle( _

   ByVal OCGId As Integer, _

   ByVal Title As String _

) As GdPictureStatus
public GdPictureStatus SetOCGTitle( 

   int OCGId,

   string Title

)
public function SetOCGTitle( 

    OCGId: Integer;

    Title: String

): GdPictureStatus; 
public function SetOCGTitle( 

   OCGId : int,

   Title : String

) : GdPictureStatus;
public: GdPictureStatus SetOCGTitle( 

   int OCGId,

   string* Title

) 
public:

GdPictureStatus SetOCGTitle( 

   int OCGId,

   String^ Title

) 

Parameters

OCGId
The unique identifier of the required OCG entry. You can obtain this identifier using the GetOCG method.
Title
The new title to be used for the specified optional content group.

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 change the title of the specified layer in the PDF document.
Dim caption As String = "Example: SetOCGTitle"

Dim gdpicturePDF As New GdPicturePDF()

'Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.

If gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", False) = GdPictureStatus.OK Then

    Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()

    Dim status As GdPictureStatus = gdpicturePDF.GetStat()

    If (status = GdPictureStatus.OK) AndAlso (ocgCount > 0) Then

        Dim ocgID As Integer = gdpicturePDF.GetOCG(0)

        status = gdpicturePDF.GetStat()

        If status = GdPictureStatus.OK Then

            If (gdpicturePDF.SetOCGTitle(ocgID, "Updated layer") = GdPictureStatus.OK) AndAlso

               (gdpicturePDF.SetOCGLockedState(ocgID, False) = GdPictureStatus.OK) AndAlso

               (gdpicturePDF.SetOCGZoomMin(ocgID, 0) = GdPictureStatus.OK) AndAlso

               (gdpicturePDF.SetOCGZoomMax(ocgID, 1) = GdPictureStatus.OK) Then

                If gdpicturePDF.SaveToFile("test_UpdatedLayer.pdf") = GdPictureStatus.OK Then

                    MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)

                Else

                    MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)

                End If

            Else

                MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)

            End If

        Else

            MessageBox.Show("The GetOCG() method has failed with the status: " + status.ToString(), caption)

        End If

    Else

        MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), caption)

    End If

Else

    MessageBox.Show("The file can't be loaded.", caption)

End If

gdpicturePDF.Dispose()
string caption = "Example: SetOCGTitle";

GdPicturePDF gdpicturePDF = new GdPicturePDF();

//Please see the example of the SetImageOptional() method for the test_ImageLayer.pdf file.

if (gdpicturePDF.LoadFromFile("test_ImageLayer.pdf", false) == GdPictureStatus.OK)

{

    int ocgCount = gdpicturePDF.GetOCGCount();

    GdPictureStatus status = gdpicturePDF.GetStat();

    if ((status == GdPictureStatus.OK) && (ocgCount > 0))

    {

        int ocgID = gdpicturePDF.GetOCG(0);

        status = gdpicturePDF.GetStat();

        if (status == GdPictureStatus.OK)

        {

            if ((gdpicturePDF.SetOCGTitle(ocgID, "Updated layer") == GdPictureStatus.OK) &&

                (gdpicturePDF.SetOCGLockedState(ocgID, false) == GdPictureStatus.OK) &&

                (gdpicturePDF.SetOCGZoomMin(ocgID, 0) == GdPictureStatus.OK) &&

                (gdpicturePDF.SetOCGZoomMax(ocgID, 1) == GdPictureStatus.OK))

            {

                if (gdpicturePDF.SaveToFile("test_UpdatedLayer.pdf") == GdPictureStatus.OK)

                {

                    MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);

                }

                else

                {

                    MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);

                }

            }

            else

            {

                MessageBox.Show("Setting up layer's options has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);

            }

        }

        else

        {

            MessageBox.Show("The GetOCG() method has failed with the status: " + status.ToString(), caption);

        }

    }

    else

    {

        MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), caption);

    }

}

else

{

    MessageBox.Show("The file can't be loaded.", caption);

}

gdpicturePDF.Dispose();
See Also