XpsDocumentWriter.WritingPrintTicketRequired 이벤트
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
Write 또는 WriteAsync 메서드가 문서 또는 인쇄 큐에 PrintTicket을 추가하기 바로 전에 발생합니다.
public:
override event System::Windows::Documents::Serialization::WritingPrintTicketRequiredEventHandler ^ WritingPrintTicketRequired;
public override event System.Windows.Documents.Serialization.WritingPrintTicketRequiredEventHandler WritingPrintTicketRequired;
member this.WritingPrintTicketRequired : System.Windows.Documents.Serialization.WritingPrintTicketRequiredEventHandler
Public Overrides Custom Event WritingPrintTicketRequired As WritingPrintTicketRequiredEventHandler
이벤트 유형
예제
다음 예제에서는 WritingPrintTicketRequired 이벤트를 사용하는 방법을 보여 줍니다.
// ---------------- PrintMultipleFixedContentDocuments ----------------
/// <summary>
/// Prints the content of a multiple fixed document sequence.</summary>
/// <param name="pq">
/// The print queue to print to.</param>
/// <param name="async">
/// true to print asynchronously; false to print synchronously.</param>
public void PrintMultipleFixedContentDocuments(PrintQueue pq, bool async)
{
// Create a multiple document FixedDocumentSequence.
FixedDocumentSequence fds =
_wpfContent.LoadFixedDocumentSequenceFromDocument();
// Create a document writer to print to.
XpsDocumentWriter xdwPrint = GetPrintXpsDocumentWriter(pq);
// Set the event handler for creating print tickets for
// each document within the fixed document sequence.
xdwPrint.WritingPrintTicketRequired +=
new WritingPrintTicketRequiredEventHandler(
MultipleFixedContentDocuments_WritingPrintTicketRequired);
_firstDocumentPrintTicket = 0;
// Print either asynchronously or synchronously.
if (async)
PrintMultipleFixedContentDocumentsAsync(xdwPrint, fds);
else
PrintMultipleFixedContentDocuments(xdwPrint, fds);
}// end:PrintMultipleFixedContentDocuments()
' ---------------- PrintMultipleFixedContentDocuments ----------------
''' <summary>
''' Prints the content of a multiple fixed document sequence.</summary>
''' <param name="pq">
''' The print queue to print to.</param>
''' <param name="async">
''' true to print asynchronously; false to print synchronously.</param>
Public Sub PrintMultipleFixedContentDocuments(ByVal pq As PrintQueue, ByVal async As Boolean)
' Create a multiple document FixedDocumentSequence.
Dim fds As FixedDocumentSequence = _wpfContent.LoadFixedDocumentSequenceFromDocument()
' Create a document writer to print to.
Dim xdwPrint As XpsDocumentWriter = GetPrintXpsDocumentWriter(pq)
' Set the event handler for creating print tickets for
' each document within the fixed document sequence.
AddHandler xdwPrint.WritingPrintTicketRequired, AddressOf MultipleFixedContentDocuments_WritingPrintTicketRequired
_firstDocumentPrintTicket = 0
' Print either asynchronously or synchronously.
If async Then
PrintMultipleFixedContentDocumentsAsync(xdwPrint, fds)
Else
PrintMultipleFixedContentDocuments(xdwPrint, fds)
End If
End Sub
이벤트 처리기는 다음 예제에서 만들어집니다.
// ----- MultipleFixedContentDocuments_WritingPrintTicketRequired -----
/// <summary>
/// Creates a PrintTicket event handler for
/// printing a FixedDocumentSequence.</summary>
private void MultipleFixedContentDocuments_WritingPrintTicketRequired(
Object sender, WritingPrintTicketRequiredEventArgs e)
{
if (e.CurrentPrintTicketLevel ==
PrintTicketLevel.FixedDocumentSequencePrintTicket)
{
// Create a PrintTicket for the FixedDocumentSequence. Any
// PrintTicket setting specified at the FixedDocumentSequence
// level will be inherited by lower level (i.e. FixedDocument or
// FixedPage) unless there exists lower level PrintTicket that
// sets the setting differently, in which case the lower level
// PrintTicket setting will override the higher level setting.
PrintTicket ptFDS = new PrintTicket();
ptFDS.PageOrientation = PageOrientation.Portrait;
ptFDS.Duplexing = Duplexing.TwoSidedLongEdge;
e.CurrentPrintTicket = ptFDS;
}
else if (e.CurrentPrintTicketLevel ==
PrintTicketLevel.FixedDocumentPrintTicket)
{
// Use different PrintTickets for different FixedDocuments.
PrintTicket ptFD = new PrintTicket();
if (_firstDocumentPrintTicket <= 1)
{ // Print the first document in black/white and in portrait
// orientation. Since the PrintTicket at the
// FixedDocumentSequence level already specifies portrait
// orientation, this FixedDocument can just inherit that
// setting without having to set it again.
ptFD.PageOrientation = PageOrientation.Portrait;
ptFD.OutputColor = OutputColor.Monochrome;
_firstDocumentPrintTicket++;
}
else // if (_firstDocumentPrintTicket > 1)
{ // Print the second document in color and in landscape
// orientation. Since the PrintTicket at the
// FixedDocumentSequence level already specifies portrait
// orientation, this FixedDocument needs to set its
// PrintTicket with landscape orientation in order to
// override the higher level setting.
ptFD.PageOrientation = PageOrientation.Landscape;
ptFD.OutputColor = OutputColor.Color;
}
e.CurrentPrintTicket = ptFD;
}// end:else if (CurrentPrintTicketLevel==FixedDocumentPrintTicket)
// Even though we don't show code for specifying PrintTicket for
// the FixedPage level, the same inheritance-override logic applies
// to FixedPage as well.
}// end:MultipleFixedContentDocuments_WritingPrintTicketRequired()
' ----- MultipleFixedContentDocuments_WritingPrintTicketRequired -----
''' <summary>
''' Creates a PrintTicket event handler for
''' printing a FixedDocumentSequence.</summary>
Private Sub MultipleFixedContentDocuments_WritingPrintTicketRequired(ByVal sender As Object, ByVal e As WritingPrintTicketRequiredEventArgs)
If e.CurrentPrintTicketLevel = PrintTicketLevel.FixedDocumentSequencePrintTicket Then
' Create a PrintTicket for the FixedDocumentSequence. Any
' PrintTicket setting specified at the FixedDocumentSequence
' level will be inherited by lower level (i.e. FixedDocument or
' FixedPage) unless there exists lower level PrintTicket that
' sets the setting differently, in which case the lower level
' PrintTicket setting will override the higher level setting.
Dim ptFDS As New PrintTicket()
ptFDS.PageOrientation = PageOrientation.Portrait
ptFDS.Duplexing = Duplexing.TwoSidedLongEdge
e.CurrentPrintTicket = ptFDS
ElseIf e.CurrentPrintTicketLevel = PrintTicketLevel.FixedDocumentPrintTicket Then
' Use different PrintTickets for different FixedDocuments.
Dim ptFD As New PrintTicket()
If _firstDocumentPrintTicket <= 1 Then
' orientation. Since the PrintTicket at the
' FixedDocumentSequence level already specifies portrait
' orientation, this FixedDocument can just inherit that
' setting without having to set it again.
ptFD.PageOrientation = PageOrientation.Portrait
ptFD.OutputColor = OutputColor.Monochrome
_firstDocumentPrintTicket += 1
Else ' if (_firstDocumentPrintTicket > 1)
' orientation. Since the PrintTicket at the
' FixedDocumentSequence level already specifies portrait
' orientation, this FixedDocument needs to set its
' PrintTicket with landscape orientation in order to
' override the higher level setting.
ptFD.PageOrientation = PageOrientation.Landscape
ptFD.OutputColor = OutputColor.Color
End If
e.CurrentPrintTicket = ptFD
End If ' end:else if (CurrentPrintTicketLevel==FixedDocumentPrintTicket)
' Even though we don't show code for specifying PrintTicket for
' the FixedPage level, the same inheritance-override logic applies
' to FixedPage as well.
End Sub
설명
WritingPrintTicketRequired 에서는 이벤트 처리기가 쓰기 작업에 전달되는 새 를 대체할 PrintTicket 수 있도록 합니다.
다음 네 Write 가지 및 WriteAsync 메서드는 이벤트를 호출 WritingPrintTicketRequired 하지 않습니다.
Write(문자열)
Write(String, XpsDocumentNotificationLevel)
WriteAsync(문자열)
WriteAsync(String, XpsDocumentNotificationLevel)
적용 대상
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET