GdPicture.NET.14
GdPicture14 Namespace / GdViewer Class / PrintSetPageSelection Method
The custom page range to be set for printing, for example, "1;4;5" to process pages 1, 4 and 5 or "1-5;10" to process pages from 1 to 5 and page 10. Set this parameter to "*" to process all pages of the current document.
Example





In This Topic
PrintSetPageSelection Method (GdViewer)
In This Topic
Sets up the required selection of pages you want to print during the next print process using the active printer.

The specified pages selection will not take into account if you will print using the PrintDialog method.

Syntax
'Declaration
 
Public Function PrintSetPageSelection( _
   ByVal CustomRange As String _
) As GdPictureStatus
public GdPictureStatus PrintSetPageSelection( 
   string CustomRange
)
public function PrintSetPageSelection( 
    CustomRange: String
): GdPictureStatus; 
public function PrintSetPageSelection( 
   CustomRange : String
) : GdPictureStatus;
public: GdPictureStatus PrintSetPageSelection( 
   string* CustomRange
) 
public:
GdPictureStatus PrintSetPageSelection( 
   String^ CustomRange
) 

Parameters

CustomRange
The custom page range to be set for printing, for example, "1;4;5" to process pages 1, 4 and 5 or "1-5;10" to process pages from 1 to 5 and page 10. Set this parameter to "*" to process all pages of the current document.

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
It is recommend to use the GetStat method or the PrintGetStat method to identify the specific reason for the method's failure, if any.

Please, be aware that the defined pages selection will not take into account if you will use the PrintDialog method.

Just to remind you that the active printer is the printer identified by the PrintGetActivePrinter method or set by the PrintSetActivePrinter method and it is dedicated to executing all subsequent print jobs using this class as well as utilizing all by you altered printer settings.

Example
How to specify the required selection of pages to print.
'We assume that the GdViewer1 control has been properly integrated.
If GdViewer1.DisplayFromFile("") = GdPictureStatus.OK Then
    GdViewer1.PrintSetPageSelection("2;6-8;10")
    If GdViewer1.GetStat() = GdPictureStatus.OK Then
        If GdViewer1.Print() = GdPictureStatus.OK Then
            MessageBox.Show("The file has been printed successfully.", "GdViewer.PrintSetPageSelection")
        Else
            Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + GdViewer1.GetStat().ToString()
            If GdViewer1.PrintGetStat() = GdPictureStatus.PrintingException Then message = message + "    Error: " + GdViewer1.PrintGetLastError()
            MessageBox.Show(message, "GdViewer.PrintSetPageSelection")
        End If
    End If
    GdViewer1.CloseDocument()
Else
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PrintSetPageSelection")
End If
//We assume that the GdViewer1 control has been properly integrated.
if (GdViewer1.DisplayFromFile("") == GdPictureStatus.OK)
{
    GdViewer1.PrintSetPageSelection("2;6-8;10");
    if (GdViewer1.GetStat() == GdPictureStatus.OK)
    {
        if (GdViewer1.Print() == GdPictureStatus.OK)
        {
            MessageBox.Show("The file has been printed successfully.", "GdViewer.PrintSetPageSelection");
        }
        else
        {
            string message = "The file can't be printed.\nStatus: " + GdViewer1.GetStat().ToString();
            if (GdViewer1.PrintGetStat() == GdPictureStatus.PrintingException)
                message = message + "    Error: " + GdViewer1.PrintGetLastError();
            MessageBox.Show(message, "GdViewer.PrintSetPageSelection");
        }
    }
    GdViewer1.CloseDocument();
}
else
{
    MessageBox.Show("The file can't be displayed. Status: " + GdViewer1.GetStat().ToString(), "GdViewer.PrintSetPageSelection");
}
See Also