The unique identifier of the required OCG entry. You can obtain this identifier using the GetOCG method.
Example





In This Topic
GdPicture14 Namespace / GdPicturePDF Class / GetOCGIntentView Method

GetOCGIntentView Method (GdPicturePDF)

In This Topic
Returns, if the value of the Intent setting of an optional content group, specified by its unique identifier, is View.

The Intent setting provides a way to distinguish between different intended uses of optional content. PDF 1.5 defines two names, View and Design, to indicate the intended use of the graphics in the optional content group.

Syntax
'Declaration

 

Public Function GetOCGIntentView( _

   ByVal OCGId As Integer _

) As Boolean
public bool GetOCGIntentView( 

   int OCGId

)
public function GetOCGIntentView( 

    OCGId: Integer

): Boolean; 
public function GetOCGIntentView( 

   OCGId : int

) : boolean;
public: bool GetOCGIntentView( 

   int OCGId

) 
public:

bool GetOCGIntentView( 

   int OCGId

) 

Parameters

OCGId
The unique identifier of the required OCG entry. You can obtain this identifier using the GetOCG method.

Return Value

true if the value of the Intent setting is View, otherwise returns false, means if the Intent setting is Design. The GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any.

Example
How to find out the Intent option of the specified layer in the PDF document.
Dim gdpicturePDF As New GdPicturePDF()

Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)

If status = GdPictureStatus.OK Then

    Dim output As String = ""

    Dim ocgCount As Integer = gdpicturePDF.GetOCGCount()

    status = gdpicturePDF.GetStat()

    If status = GdPictureStatus.OK Then

        output = "The number of OCG layers: " + ocgCount.ToString()

        Dim OcgId As Integer = 0

        Dim title As String = ""

        Dim onOff As Boolean = False

        For i As Integer = 0 To ocgCount - 1

            output = output + vbCrLf + "Nr." + (i + 1).ToString() + ": "

            OcgId = gdpicturePDF.GetOCG(i)

            status = gdpicturePDF.GetStat()

            If status = GdPictureStatus.OK Then

                title = gdpicturePDF.GetOCGTitle(OcgId)

                status = gdpicturePDF.GetStat()

                If status = GdPictureStatus.OK Then

                    output = output + "Title = " + title.ToString()

                Else

                    output = output + "Title = Error (" + status.ToString() + ")"

                End If

            

                onOff = gdpicturePDF.GetOCGIntentView(OcgId)

                status = gdpicturePDF.GetStat()

                If status = GdPictureStatus.OK Then

                    If onOff Then

                        output = output + "    Intent = View"

                    Else

                        output = output + "    Intent = Design"

                    End If

                Else

                    output = output + "    Intent = Error (" + status.ToString() + ")"

                End If

            Else

                output = output + "The GetOCG() method has failed with the status: " + status.ToString()

            End If

        Next

        MessageBox.Show(output, "Example: GetOCGIntentView")

    Else

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

    End If

Else

    MessageBox.Show("The file can't be loaded.", "Example: GetOCGIntentView")

End If

gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();

GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);

if (status == GdPictureStatus.OK)

{

    string output = "";

    int ocgCount = gdpicturePDF.GetOCGCount();

    status = gdpicturePDF.GetStat();

    if (status == GdPictureStatus.OK)

    {

        output = "The number of OCG layers: " + ocgCount.ToString();

        int OcgId = 0;

        string title = "";

        bool onOff = false;

        for (int i = 0; i < ocgCount; i++)

        {

            output = output + "\nNr." + (i + 1).ToString() + ": ";

            OcgId = gdpicturePDF.GetOCG(i);

            status = gdpicturePDF.GetStat();

            if (status == GdPictureStatus.OK)

            {

                title = gdpicturePDF.GetOCGTitle(OcgId);

                status = gdpicturePDF.GetStat();

                if (status == GdPictureStatus.OK)

                    output = output + "Title = " + title.ToString();

                else

                    output = output + "Title = Error (" + status.ToString() + ")";

            

                onOff = gdpicturePDF.GetOCGIntentView(OcgId);

                status = gdpicturePDF.GetStat();

                if (status == GdPictureStatus.OK)

                {

                    if (onOff)

                        output = output + "    Intent = View";

                    else

                        output = output + "    Intent = Design";

                }

                else

                    output = output + "    Intent = Error (" + status.ToString() + ")";

            }

            else

                output = output + "The GetOCG() method has failed with the status: " + status.ToString();

        }

        MessageBox.Show(output, "Example: GetOCGIntentView");

    }

    else

    {

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

    }

}

else

{

    MessageBox.Show("The file can't be loaded.", "Example: GetOCGIntentView");

}

gdpicturePDF.Dispose();
See Also