GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF 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 (GdPicturePDF)
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 or the PrintDialogFit methods.

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.

Be aware that the defined pages selection will not take into account if you will use the PrintDialog or the PrintDialogFit methods.

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.
Dim caption As String = "Example: PrintSetPageSelection"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    If gdpicturePDF.LoadFromFile("document_to_print.pdf", False) = GdPictureStatus.OK Then
        gdpicturePDF.PrintSetPageSelection("2;6-8;10")
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            If gdpicturePDF.Print() = GdPictureStatus.OK Then
                MessageBox.Show("The file has been printed successfully.", caption)
            Else
                Dim message As String = "The file can't be printed." + vbCrLf + "Status: " + gdpicturePDF.GetStat().ToString()
                If gdpicturePDF.PrintGetStat() = GdPictureStatus.PrintingException Then
                    message = message + "    Error: " + gdpicturePDF.PrintGetLastError()
                End If
                MessageBox.Show(message, caption)
            End If
        End If
        gdpicturePDF.CloseDocument()
    Else
        MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
End Using
string caption = "Example: PrintSetPageSelection";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    if (gdpicturePDF.LoadFromFile("document_to_print.pdf", false) == GdPictureStatus.OK)
    {
        gdpicturePDF.PrintSetPageSelection("2;6-8;10");
        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
        {
            if (gdpicturePDF.Print() == GdPictureStatus.OK)
            {
                MessageBox.Show("The file has been printed successfully.", caption);
            }
            else
            {
                string message = "The file can't be printed.\nStatus: " + gdpicturePDF.GetStat().ToString();
                if (gdpicturePDF.PrintGetStat() == GdPictureStatus.PrintingException)
                    message = message + "    Error: " + gdpicturePDF.PrintGetLastError();
                MessageBox.Show(message, caption);
            }
        }
        gdpicturePDF.CloseDocument();
    }
    else
    {
        MessageBox.Show("The file can't be loaded. Status: " + gdpicturePDF.GetStat().ToString(), caption);
    }
}
See Also