次の方法で共有


PrintQueue.GetPrintCapabilities メソッド

定義

カラー印刷や両面印刷に対応しているかどうかなど、プリンターやデバイスの機能を識別する PrintCapabilities オブジェクトを取得します。

オーバーロード

GetPrintCapabilities()

プリンターの機能を識別する PrintCapabilities オブジェクトを取得します。

GetPrintCapabilities(PrintTicket)

プリンターの機能を識別する PrintCapabilities オブジェクトを取得します。

GetPrintCapabilities()

プリンターの機能を識別する PrintCapabilities オブジェクトを取得します。

public:
 System::Printing::PrintCapabilities ^ GetPrintCapabilities();
public System.Printing.PrintCapabilities GetPrintCapabilities ();
member this.GetPrintCapabilities : unit -> System.Printing.PrintCapabilities
Public Function GetPrintCapabilities () As PrintCapabilities

戻り値

両面処理や自動ステープル処理など、プリンターが実行できる処理および実行できない処理を指定する PrintCapabilities オブジェクト。

例外

PrintCapabilities オブジェクトを取得できませんでした。

次の例は、2 つの印刷チケットをマージするときにこのメソッドを使用する方法を示しています。

/// <summary>
/// Changes the user-default PrintTicket setting of the specified print queue.
/// </summary>
/// <param name="queue">the printer whose user-default PrintTicket setting needs to be changed</param>
static private void ChangePrintTicketSetting(PrintQueue queue)
{
    //
    // Obtain the printer's PrintCapabilities so we can determine whether or not
    // duplexing printing is supported by the printer.
    //
    PrintCapabilities printcap = queue.GetPrintCapabilities();

    //
    // The printer's duplexing capability is returned as a read-only collection of duplexing options
    // that can be supported by the printer. If the collection returned contains the duplexing
    // option we want to set, it means the duplexing option we want to set is supported by the printer,
    // so we can make the user-default PrintTicket setting change.
    //
    if (printcap.DuplexingCapability.Contains(Duplexing.TwoSidedLongEdge))
    {
        //
        // To change the user-default PrintTicket, we can first create a delta PrintTicket with
        // the new duplexing setting.
        //
        PrintTicket deltaTicket = new PrintTicket();
        deltaTicket.Duplexing = Duplexing.TwoSidedLongEdge;

        //
        // Then merge the delta PrintTicket onto the printer's current user-default PrintTicket,
        // and validate the merged PrintTicket to get the new PrintTicket we want to set as the
        // printer's new user-default PrintTicket.
        //
        ValidationResult result = queue.MergeAndValidatePrintTicket(queue.UserPrintTicket, deltaTicket);

        //
        // The duplexing option we want to set could be constrained by other PrintTicket settings
        // or device settings. We can check the validated merged PrintTicket to see whether the
        // the validation process has kept the duplexing option we want to set unchanged.
        //
        if (result.ValidatedPrintTicket.Duplexing == Duplexing.TwoSidedLongEdge)
        {
            //
            // Set the printer's user-default PrintTicket and commit the set operation.
            //
            queue.UserPrintTicket = result.ValidatedPrintTicket;
            queue.Commit();
            Console.WriteLine("PrintTicket new duplexing setting is set on '{0}'.", queue.FullName);
        }
        else
        {
            //
            // The duplexing option we want to set has been changed by the validation process
            // when it was resolving setting constraints.
            //
            Console.WriteLine("PrintTicket new duplexing setting is constrained on '{0}'.", queue.FullName);
        }
    }
    else
    {
        //
        // If the printer doesn't support the duplexing option we want to set, skip it.
        //
        Console.WriteLine("PrintTicket new duplexing setting is not supported on '{0}'.", queue.FullName);
    }
}
''' <summary>
''' Changes the user-default PrintTicket setting of the specified print queue.
''' </summary>
''' <param name="queue">the printer whose user-default PrintTicket setting needs to be changed</param>
Private Shared Sub ChangePrintTicketSetting(ByVal queue As PrintQueue)
    '
    ' Obtain the printer's PrintCapabilities so we can determine whether or not
    ' duplexing printing is supported by the printer.
    '
    Dim printcap As PrintCapabilities = queue.GetPrintCapabilities()

    '
    ' The printer's duplexing capability is returned as a read-only collection of duplexing options
    ' that can be supported by the printer. If the collection returned contains the duplexing
    ' option we want to set, it means the duplexing option we want to set is supported by the printer,
    ' so we can make the user-default PrintTicket setting change.
    '
    If printcap.DuplexingCapability.Contains(Duplexing.TwoSidedLongEdge) Then
        '
        ' To change the user-default PrintTicket, we can first create a delta PrintTicket with
        ' the new duplexing setting.
        '
        Dim deltaTicket As New PrintTicket()
        deltaTicket.Duplexing = Duplexing.TwoSidedLongEdge

        '
        ' Then merge the delta PrintTicket onto the printer's current user-default PrintTicket,
        ' and validate the merged PrintTicket to get the new PrintTicket we want to set as the
        ' printer's new user-default PrintTicket.
        '
        Dim result As ValidationResult = queue.MergeAndValidatePrintTicket(queue.UserPrintTicket, deltaTicket)

        '
        ' The duplexing option we want to set could be constrained by other PrintTicket settings
        ' or device settings. We can check the validated merged PrintTicket to see whether the
        ' the validation process has kept the duplexing option we want to set unchanged.
        '
        If result.ValidatedPrintTicket.Duplexing = Duplexing.TwoSidedLongEdge Then
            '
            ' Set the printer's user-default PrintTicket and commit the set operation.
            '
            queue.UserPrintTicket = result.ValidatedPrintTicket
            queue.Commit()
            Console.WriteLine("PrintTicket new duplexing setting is set on '{0}'.", queue.FullName)
        Else
            '
            ' The duplexing option we want to set has been changed by the validation process
            ' when it was resolving setting constraints.
            '
            Console.WriteLine("PrintTicket new duplexing setting is constrained on '{0}'.", queue.FullName)
        End If
    Else
        '
        ' If the printer doesn't support the duplexing option we want to set, skip it.
        '
        Console.WriteLine("PrintTicket new duplexing setting is not supported on '{0}'.", queue.FullName)
    End If
End Sub

適用対象

GetPrintCapabilities(PrintTicket)

プリンターの機能を識別する PrintCapabilities オブジェクトを取得します。

public:
 System::Printing::PrintCapabilities ^ GetPrintCapabilities(System::Printing::PrintTicket ^ printTicket);
[System.Security.SecurityCritical]
public System.Printing.PrintCapabilities GetPrintCapabilities (System.Printing.PrintTicket printTicket);
public System.Printing.PrintCapabilities GetPrintCapabilities (System.Printing.PrintTicket printTicket);
[<System.Security.SecurityCritical>]
member this.GetPrintCapabilities : System.Printing.PrintTicket -> System.Printing.PrintCapabilities
member this.GetPrintCapabilities : System.Printing.PrintTicket -> System.Printing.PrintCapabilities
Public Function GetPrintCapabilities (printTicket As PrintTicket) As PrintCapabilities

パラメーター

printTicket
PrintTicket

印刷機能を報告するための基準となる印刷チケット。

戻り値

両面処理や自動ステープル処理など、プリンターが実行できる処理および実行できない処理を指定する PrintCapabilities オブジェクト。

属性

例外

PrintCapabilities オブジェクトを取得できませんでした。

printTicket の形式が正しくありません。

注釈

パラメーターは PrintTicket 、オブジェクトを構築 PrintCapabilities するための基礎として使用されます。 たとえば、プリンターが入力ビン 1 のメディア・タイプ A と B のみをサポートし、入力ビン 2 のメディア・タイプ C のみをサポートしたとします。 パラメーターが printTicket 入力ビン 1 を指定した場合、 PrintCapabilities 返されるオブジェクトには 3 つのメディアの種類がすべて含まれますが、型 C は "制約付き" と報告されます。パラメーターが printTicket 入力ビン 2 を指定した場合、 PrintCapabilities 返されるオブジェクトには 3 つのメディアの種類がすべて含まれますが、型 A と B は "制約付き" として報告されます。制約の詳細については、「 印刷スキーマ 」を参照してください。

が のnull場合printTicketUserPrintTicket が使用されます。

適用対象