PrintTicket 생성자

정의

PrintTicket 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the PrintTicket class.

오버로드

PrintTicket()

PrintTicket 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the PrintTicket class.

PrintTicket(Stream)

XML 인쇄 스키마를 준수하는 XML 스트림(PrintTicket 문서가 포함된 스트림)을 사용하여 PrintTicket 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the PrintTicket class by using an XML stream (that contains a PrintTicket document) that complies with the XML Print Schema.

PrintTicket()

PrintTicket 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the PrintTicket class.

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

예제

다음 예제에서는 두 인쇄 티켓을 병합 하는 동안이 생성자를 사용 하는 방법을 보여 줍니다.The following example shows how to use this constructor while merging two print tickets.

/// <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 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the PrintTicket class by using an XML stream (that contains a PrintTicket document) that complies with the XML Print Schema.

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 스트림입니다.An XML stream that describes a print job and conforms to the Print Schema.

예외

xmlStream이(가) null인 경우xmlStream is null.

xmlStream이 유효한 XML이 아닌 경우xmlStream is not valid XML.

설명

생성자는 원래 위치로 다시 스트림의 읽기 / 쓰기 위치를 설정 하지 않습니다.The constructor does not reset the read-write position of the stream back to its original position. 따라서 생성자를 호출한 후 즉시 재설정 해야 합니다.Accordingly, you should reset it immediately after calling the constructor.

전체 PrintTicket 문서가의 공용 속성으로 표현 되지 않는 특수 기능을 표현 하는 XML 요소를 포함 하 여 개체의 public이 아닌 필드에 저장 된 된 PrintTicket 클래스입니다.The entire PrintTicket document is stored in a non-public field in the object, including the XML elements within it that express less common features that are not represented by any of the public properties of the PrintTicket class. 사실 PrintTicket 문서가 생성 되는 드라이버의 프라이빗 확장을 사용 하는 경우는 Print Schema개인적으로 정의된 태그는 public이 아닌 PrintTicket 문서의 일부로 저장됩니다.In fact, if the driver that produced the PrintTicket document is using a private extension of the Print Schema, that privately defined markup is also stored as part of the non-public PrintTicket document.

프라이빗 부분 문서에 있는 경우 유효성이 검사되지 않습니다 생성자에서 모든 Print Schema-정의된 파트의 퍼블릭 속성으로 표현되지 않는 부분을 포함하여 확인되는 PrintTicket 클래스입니다.The private parts of the document, if any, are not validated by the constructor, but all Print Schema-defined parts are validated, including the parts that are not represented by any of the public properties of the PrintTicket class. 따라서는 FormatException 모든 공용 속성에 해당 하는 XML 태그는 유효한 경우에 발생할 수 있습니다.Accordingly, the FormatException could be thrown even if all of the XML markup that corresponds to the public properties is valid.

속성의 경우는 PrintTicket 기록할지, public이 아닌 PrintTicket 문서가이 변경 됩니다.When any of the properties of the PrintTicket are written to, this non-public PrintTicket document is changed as well.

이 public이 아닌 PrintTicket 문서가에서 반환 되는 것은 GetXmlStreamSaveTo 메서드.It is this non-public PrintTicket document that is returned by the GetXmlStream and SaveTo methods.

추가 정보

적용 대상