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 개체를 검색할 수 없는 경우

예제

다음 예제에서는 두 개의 인쇄 티켓을 병합하는 동안 이 메서드를 사용하는 방법을 보여 주었습니다.

/// <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 할 기준으로 사용됩니다. 예를 들어 프린터는 입력 bin 1에서 미디어 형식 A 및 B만 지원하며 입력 bin 2의 미디어 형식 C만 지원한다고 가정합니다. 매개 변수가 printTicket 입력 bin 1 PrintCapabilities 을 지정한 경우 반환되는 개체에는 세 가지 미디어 형식이 모두 포함되지만 C 형식은 "제한됨"으로 보고됩니다. 매개 변수가 printTicket 입력 bin 2 PrintCapabilities 를 지정한 경우 반환되는 개체에는 세 가지 미디어 형식이 모두 포함되지만 A 및 B 형식은 "제한됨"으로 보고됩니다. 제약 조건에 대한 자세한 내용은 인쇄 스키마 를 참조하세요.

가 이nullprintTicketUserPrintTicket 사용됩니다.

적용 대상