GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / GetOCGZoomMax Method
The unique identifier of the required OCG entry. You can obtain this identifier using the GetOCG method.
Example





In This Topic
GetOCGZoomMax Method (GdPicturePDF)
In This Topic
Returns the maximum magnification factor of an optional content group, specified by its unique identifier.

It is the maximum value of a defined range of magnifications below which the content of this optional content group is best viewed.

Syntax
'Declaration
 
Public Function GetOCGZoomMax( _
   ByVal OCGId As Integer _
) As Double
public double GetOCGZoomMax( 
   int OCGId
)
public function GetOCGZoomMax( 
    OCGId: Integer
): Double; 
public function GetOCGZoomMax( 
   OCGId : int
) : double;
public: double GetOCGZoomMax( 
   int OCGId
) 
public:
double GetOCGZoomMax( 
   int OCGId
) 

Parameters

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

Return Value

The maximum magnification factor below which the content of the specified OCG is best viewed. 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.

Be aware that some viewers can interpret this value as the maximum value of a defined range of magnifications below which the content of this optional content group is viewed, meaning that when zooming greater the content will not display.

Example
How to find out the range of magnifications 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
        Dim zoom As Double = 0
        For i As Integer = 0 To ocgCount - 1
            output = output + vbCrLf + "Layer 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
            
                zoom = gdpicturePDF.GetOCGZoomMin(OcgId)
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    output = output + vbCrLf + "       zoomMin = " + String.Format("{0:0.00}", zoom)
                Else
                    output = output + vbCrLf + "       zoomMin = Error (" + status.ToString() + ")"
                End If
            
                zoom = gdpicturePDF.GetOCGZoomMax(OcgId)
                status = gdpicturePDF.GetStat()
                If status = GdPictureStatus.OK Then
                    output = output + "    zoomMax = " + String.Format("{0:0.00}", zoom)
                Else
                    output = output + "    zoomMax = 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: GetOCGZoomMax")
    Else
        MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGZoomMax")
    End If
Else
    MessageBox.Show("The file can't be loaded.", "Example: GetOCGZoomMax")
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;
        double zoom = 0;
        for (int i = 0; i < ocgCount; i++)
        {
            output = output + "\nLayer nr." + (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() + ")";
            
                zoom = gdpicturePDF.GetOCGZoomMin(OcgId);
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                    output = output + "\n       zoomMin = " + string.Format("{0:0.00}", zoom);
                else
                    output = output + "\n       zoomMin = Error (" + status.ToString() + ")";
            
                zoom = gdpicturePDF.GetOCGZoomMax(OcgId);
                status = gdpicturePDF.GetStat();
                if (status == GdPictureStatus.OK)
                    output = output + "    zoomMax = " + string.Format("{0:0.00}", zoom);
                else
                    output = output + "    zoomMax = Error (" + status.ToString() + ")";
            }
            else
                output = output + "The GetOCG() method has failed with the status: " + status.ToString();
        }
        MessageBox.Show(output, "Example: GetOCGZoomMax");
    }
    else
    {
        MessageBox.Show("The GetOCGCount() method has failed with the status: " + status.ToString(), "Example: GetOCGZoomMax");
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", "Example: GetOCGZoomMax");
}
gdpicturePDF.Dispose();
See Also