GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / GetViewerPreference Method
A member of the PdfViewerPreference enumeration. You have to specify the name of the preference you want to find out if it is enabled or not.
Example





In This Topic
GetViewerPreference Method (GdPicturePDF)
In This Topic
Finds out if the specified viewer preference setting is enabled or not. 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 GetViewerPreference( _
   ByVal Preference As PdfViewerPreference _
) As Boolean
public bool GetViewerPreference( 
   PdfViewerPreference Preference
)
public function GetViewerPreference( 
    Preference: PdfViewerPreference
): Boolean; 
public function GetViewerPreference( 
   Preference : PdfViewerPreference
) : boolean;
public: bool GetViewerPreference( 
   PdfViewerPreference Preference
) 
public:
bool GetViewerPreference( 
   PdfViewerPreference Preference
) 

Parameters

Preference
A member of the PdfViewerPreference enumeration. You have to specify the name of the preference you want to find out if it is enabled or not.

Return Value

true if the specified preference is enabled, otherwise false. The default value is false.

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 which viewer preference settings are enabled and which are disabled.
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("test.pdf", False)
If status = GdPictureStatus.OK Then
    Dim PreferenceFound As Boolean
    PreferenceFound = gdpicturePDF.GetViewerPreference(PdfViewerPreference.PdfViewerPreferenceCenterWindow)
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
    'The required preference is defined for the currently loaded PDF document.
        If PreferenceFound = True Then
            'The preference is enabled.
            MessageBox.Show("The position of the document's window is set to be in the center of the screen.", "Example: GetViewerPreference")
        Else
            'The preference is disabled.
            MessageBox.Show("The position of the document's window is set not to be in the center of the screen.", "Example: GetViewerPreference")
        End If
    Else
        MessageBox.Show("The GetViewerPreference() method has failed with the status: " + status.ToString(), "Example: GetViewerPreference")
    End If
Else
   MessageBox.Show("The file can't be loaded.", "Example: GetViewerPreference")
End If
gdpicturePDF.Dispose()
            
'You can do the same for other viewer preferences:
'PdfViewerPreference.PdfViewerPreferenceHideToolbar specifies that the viewer application's tool bars will be hidden when the document is active.
'PdfViewerPreference.PdfViewerPreferenceHideMenubar specifies that the viewer application's menu bar will be hidden when the document is active.
'PdfViewerPreference.PdfViewerPreferenceHideWindowUI specifies that the user interface elements in the document's window (such as scroll bars and navigation controls) will be hidden, leaving only the document's content displayed.
'PdfViewerPreference.PdfViewerPreferenceFitWindow specifies that the document's window will be resized to fit the size of the first displayed page.
'PdfViewerPreference.PdfViewerPreferenceDisplayDocTitle specifies that the window's title bar should display the document title taken from the document information dictionary.
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("test.pdf", false);
if (status == GdPictureStatus.OK)
{
    bool PreferenceFound = gdpicturePDF.GetViewerPreference(PdfViewerPreference.PdfViewerPreferenceCenterWindow);
    status = gdpicturePDF.GetStat();
    //The required preference is defined for the currently loaded PDF document.
    if (status == GdPictureStatus.OK)
    {
        if (PreferenceFound)
        {
            //The preference is enabled.
            MessageBox.Show("The position of the document's window is set to be in the center of the screen.", "Example: GetViewerPreference");
        }
        else
        {
            //The preference is disabled.
            MessageBox.Show("The position of the document's window is set not to be in the center of the screen.", "Example: GetViewerPreference");
        }
    }
    else
    {
        MessageBox.Show("The GetViewerPreference() method has failed with the status: " + status.ToString(), "Example: GetViewerPreference");
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", "Example: GetViewerPreference");
}
gdpicturePDF.Dispose();
            
//You can do the same for other viewer preferences:
//PdfViewerPreference.PdfViewerPreferenceHideToolbar specifies that the viewer application's tool bars will be hidden when the document is active.
//PdfViewerPreference.PdfViewerPreferenceHideMenubar specifies that the viewer application's menu bar will be hidden when the document is active.
//PdfViewerPreference.PdfViewerPreferenceHideWindowUI specifies that the user interface elements in the document's window (such as scroll bars and navigation controls) will be hidden, leaving only the document's content displayed.
//PdfViewerPreference.PdfViewerPreferenceFitWindow specifies that the document's window will be resized to fit the size of the first displayed page.
//PdfViewerPreference.PdfViewerPreferenceDisplayDocTitle specifies that the window's title bar should display the document title taken from the document information dictionary.
See Also