GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / SetViewerPreference Method
A member of the PdfViewerPreference enumeration. You have to specify the name of the preference you want to enable or disable.
Set this parameter to true if you want to enable the specified preference setting. If you set this parameter to false, the specified preference setting will be disabled.
Example





In This Topic
SetViewerPreference Method (GdPicturePDF)
In This Topic
Sets up different viewer preference settings. These preferences, if defined, control the way the document is to be presented on the screen in Adobe Reader or Acrobat viewer.
Syntax
'Declaration
 
Public Function SetViewerPreference( _
   ByVal Preference As PdfViewerPreference, _
   ByVal Enable As Boolean _
) As GdPictureStatus
public GdPictureStatus SetViewerPreference( 
   PdfViewerPreference Preference,
   bool Enable
)
public function SetViewerPreference( 
    Preference: PdfViewerPreference;
    Enable: Boolean
): GdPictureStatus; 
public function SetViewerPreference( 
   Preference : PdfViewerPreference,
   Enable : boolean
) : GdPictureStatus;
public: GdPictureStatus SetViewerPreference( 
   PdfViewerPreference Preference,
   bool Enable
) 
public:
GdPictureStatus SetViewerPreference( 
   PdfViewerPreference Preference,
   bool Enable
) 

Parameters

Preference
A member of the PdfViewerPreference enumeration. You have to specify the name of the preference you want to enable or disable.
Enable
Set this parameter to true if you want to enable the specified preference setting. If you set this parameter to false, the specified preference setting will be disabled.

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 enable or disable required viewer preference settings.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
    'The specified preference will be enabled.
    status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceFitWindow, True)
    If status = GdPictureStatus.OK Then
        'The specified preference will be enabled.
        status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceHideWindowUI, True)
        If status = GdPictureStatus.OK Then
            'The specified preference will be disabled.
            status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceDisplayDocTitle, False)
            If status = GdPictureStatus.OK Then
                If gdpicturePDF.SaveToFile("test_SetViewerPreference_func.pdf", False) = GdPictureStatus.OK Then
                    MessageBox.Show("Your specified preference settings have been set successfully.", "Example: SetViewerPreference")
                End If
            Else
                MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference")
            End If
        Else
            MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference")
        End If
    Else
        MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference")
    End If
Else
    MessageBox.Show("The file can't be loaded.", "Example: SetViewerPreference")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
    'The specified preference will be enabled.
    status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceFitWindow, true);
    if (status == GdPictureStatus.OK)
    {
        'The specified preference will be enabled.
        status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceHideWindowUI, true);
        if (status == GdPictureStatus.OK)
        {
            'The specified preference will be disabled.
            status = gdpicturePDF.SetViewerPreference(PdfViewerPreference.PdfViewerPreferenceDisplayDocTitle, false);
            if (status == GdPictureStatus.OK)
            {
                if (gdpicturePDF.SaveToFile("test_SetViewerPreference_func.pdf", false) == GdPictureStatus.OK)
                    MessageBox.Show("Your specified preference settings have been set successfully.", "Example: SetViewerPreference");
            }
            else
            {
                MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference");
            }
        }
        else
        {
            MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference");
        }
    }
    else
    {
        MessageBox.Show("The SetViewerPreference() method has failed with the status: " + status.ToString(), "Example: SetViewerPreference");
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", "Example: SetViewerPreference");
}
gdpicturePDF.Dispose();
See Also