PrintTicket コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
PrintTicket クラスの新しいインスタンスを初期化します。
オーバーロード
| 名前 | 説明 |
|---|---|
| PrintTicket() |
PrintTicket クラスの新しいインスタンスを初期化します。 |
| PrintTicket(Stream) |
XML PrintTicketに準拠する XML ストリーム (PrintTicket ドキュメントを含む) を使用して、 クラスの新しいインスタンスを初期化します。 |
PrintTicket()
PrintTicket クラスの新しいインスタンスを初期化します。
public:
PrintTicket();
public PrintTicket();
Public Sub New ()
例
次の例は、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
適用対象
PrintTicket(Stream)
XML PrintTicketに準拠する XML ストリーム (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 ドキュメント全体は、オブジェクト内の非パブリック フィールドに格納されます。これには、 PrintTicket クラスのどのパブリック プロパティでも表されないあまり一般的でない機能を表す XML 要素が含まれます。 実際、PrintTicket ドキュメントを生成したドライバーが 印刷スキーマのプライベート拡張を使用している場合、そのプライベートに定義されたマークアップも、パブリックでない PrintTicket ドキュメントの一部として格納されます。
ドキュメントのプライベート部分 (存在する場合) はコンストラクターによって検証されませんが、 印刷スキーマで定義されたすべての部分 ( PrintTicket クラスのパブリック プロパティで表されていない部分を含む) が検証されます。 したがって、パブリック プロパティに対応するすべての XML マークアップが有効な場合でも、 FormatException がスローされる可能性があります。
PrintTicketのいずれかのプロパティが書き込まれると、このパブリックでない PrintTicket ドキュメントも変更されます。
この非パブリック PrintTicket ドキュメントは、 GetXmlStream メソッドおよび SaveTo メソッドによって返されます。