PrintTicket 생성자

정의

PrintTicket 클래스의 새 인스턴스를 초기화합니다.

오버로드

PrintTicket()

PrintTicket 클래스의 새 인스턴스를 초기화합니다.

PrintTicket(Stream)

XML 인쇄 스키마를 준수하는 XML 스트림(PrintTicket 문서가 포함된 스트림)을 사용하여 PrintTicket 클래스의 새 인스턴스를 초기화합니다.

PrintTicket()

PrintTicket 클래스의 새 인스턴스를 초기화합니다.

public:
 PrintTicket();
public PrintTicket ();
Public Sub New ()

예제

다음 예제에서는 두 인쇄 티켓을 병합 하는 동안이 생성자를 사용 하는 방법을 보여 줍니다.

/// <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

적용 대상

PrintTicket(Stream)

XML 인쇄 스키마를 준수하는 XML 스트림(PrintTicket 문서가 포함된 스트림)을 사용하여 PrintTicket 클래스의 새 인스턴스를 초기화합니다.

public:
 PrintTicket(System::IO::Stream ^ xmlStream);
public PrintTicket (System.IO.Stream xmlStream);
new System.Printing.PrintTicket : System.IO.Stream -> System.Printing.PrintTicket
Public Sub New (xmlStream As Stream)

매개 변수

xmlStream
Stream

인쇄 작업에 대해 설명하며 인쇄 스키마를 준수하는 XML 스트림입니다.

예외

xmlStream이(가) null인 경우

xmlStream이 유효한 XML이 아닌 경우

설명

생성자는 원래 위치로 다시 스트림의 읽기 / 쓰기 위치를 설정 하지 않습니다. 따라서 생성자를 호출한 후 즉시 재설정 해야 합니다.

전체 PrintTicket 문서가의 공용 속성으로 표현 되지 않는 특수 기능을 표현 하는 XML 요소를 포함 하 여 개체의 public이 아닌 필드에 저장 된 된 PrintTicket 클래스입니다. 사실 PrintTicket 문서가 생성 되는 드라이버의 프라이빗 확장을 사용 하는 경우는 Print Schema개인적으로 정의된 태그는 public이 아닌 PrintTicket 문서의 일부로 저장됩니다.

프라이빗 부분 문서에 있는 경우 유효성이 검사되지 않습니다 생성자에서 모든 Print Schema-정의된 파트의 퍼블릭 속성으로 표현되지 않는 부분을 포함하여 확인되는 PrintTicket 클래스입니다. 따라서는 FormatException 모든 공용 속성에 해당 하는 XML 태그는 유효한 경우에 발생할 수 있습니다.

속성의 경우는 PrintTicket 기록할지, public이 아닌 PrintTicket 문서가이 변경 됩니다.

이 public이 아닌 PrintTicket 문서가에서 반환 되는 것은 GetXmlStreamSaveTo 메서드.

추가 정보

적용 대상