PrintCapabilities クラス

定義

プリンターの機能を定義します。

public ref class PrintCapabilities sealed
public sealed class PrintCapabilities
type PrintCapabilities = class
Public NotInheritable Class PrintCapabilities
継承
PrintCapabilities

次の例では、特定のプリンターの機能を確認する方法と、それらを利用するように印刷ジョブを構成する方法を示します。

// ---------------------- GetPrintTicketFromPrinter -----------------------
/// <summary>
///   Returns a PrintTicket based on the current default printer.</summary>
/// <returns>
///   A PrintTicket for the current local default printer.</returns>
PrintTicket^ GetPrintTicketFromPrinter ()
{
   PrintQueue^ printQueue = nullptr;

   LocalPrintServer^ localPrintServer = gcnew LocalPrintServer();

   // Retrieving collection of local printer on user machine
   PrintQueueCollection^ localPrinterCollection = localPrintServer->GetPrintQueues();

   System::Collections::IEnumerator^ localPrinterEnumerator = localPrinterCollection->GetEnumerator();

   if (localPrinterEnumerator->MoveNext())
   {
      // Get PrintQueue from first available printer
      printQueue = ((PrintQueue^)localPrinterEnumerator->Current);
   } else
   {
      return nullptr;
   }
   // Get default PrintTicket from printer
   PrintTicket^ printTicket = printQueue->DefaultPrintTicket;

   PrintCapabilities^ printCapabilities = printQueue->GetPrintCapabilities();

   // Modify PrintTicket
   if (printCapabilities->CollationCapability->Contains(Collation::Collated))
   {
      printTicket->Collation = Collation::Collated;
   }
   if (printCapabilities->DuplexingCapability->Contains(Duplexing::TwoSidedLongEdge))
   {
      printTicket->Duplexing = Duplexing::TwoSidedLongEdge;
   }
   if (printCapabilities->StaplingCapability->Contains(Stapling::StapleDualLeft))
   {
      printTicket->Stapling = Stapling::StapleDualLeft;
   }
   return printTicket;
};// end:GetPrintTicketFromPrinter()
// ---------------------- GetPrintTicketFromPrinter -----------------------
/// <summary>
///   Returns a PrintTicket based on the current default printer.</summary>
/// <returns>
///   A PrintTicket for the current local default printer.</returns>
private PrintTicket GetPrintTicketFromPrinter()
{
    PrintQueue printQueue = null;

    LocalPrintServer localPrintServer = new LocalPrintServer();

    // Retrieving collection of local printer on user machine
    PrintQueueCollection localPrinterCollection =
        localPrintServer.GetPrintQueues();

    System.Collections.IEnumerator localPrinterEnumerator =
        localPrinterCollection.GetEnumerator();

    if (localPrinterEnumerator.MoveNext())
    {
        // Get PrintQueue from first available printer
        printQueue = (PrintQueue)localPrinterEnumerator.Current;
    }
    else
    {
        // No printer exist, return null PrintTicket
        return null;
    }

    // Get default PrintTicket from printer
    PrintTicket printTicket = printQueue.DefaultPrintTicket;

    PrintCapabilities printCapabilities = printQueue.GetPrintCapabilities();

    // Modify PrintTicket
    if (printCapabilities.CollationCapability.Contains(Collation.Collated))
    {
        printTicket.Collation = Collation.Collated;
    }

    if ( printCapabilities.DuplexingCapability.Contains(
            Duplexing.TwoSidedLongEdge) )
    {
        printTicket.Duplexing = Duplexing.TwoSidedLongEdge;
    }

    if (printCapabilities.StaplingCapability.Contains(Stapling.StapleDualLeft))
    {
        printTicket.Stapling = Stapling.StapleDualLeft;
    }

    return printTicket;
}// end:GetPrintTicketFromPrinter()
' ---------------------- GetPrintTicketFromPrinter -----------------------
''' <summary>
'''   Returns a PrintTicket based on the current default printer.</summary>
''' <returns>
'''   A PrintTicket for the current local default printer.</returns>
Private Function GetPrintTicketFromPrinter() As PrintTicket
    Dim printQueue As PrintQueue = Nothing

    Dim localPrintServer As New LocalPrintServer()

    ' Retrieving collection of local printer on user machine
    Dim localPrinterCollection As PrintQueueCollection = localPrintServer.GetPrintQueues()

    Dim localPrinterEnumerator As System.Collections.IEnumerator = localPrinterCollection.GetEnumerator()

    If localPrinterEnumerator.MoveNext() Then
        ' Get PrintQueue from first available printer
        printQueue = CType(localPrinterEnumerator.Current, PrintQueue)
    Else
        ' No printer exist, return null PrintTicket
        Return Nothing
    End If

    ' Get default PrintTicket from printer
    Dim printTicket As PrintTicket = printQueue.DefaultPrintTicket

    Dim printCapabilities As PrintCapabilities = printQueue.GetPrintCapabilities()

    ' Modify PrintTicket
    If printCapabilities.CollationCapability.Contains(Collation.Collated) Then
        printTicket.Collation = Collation.Collated
    End If

    If printCapabilities.DuplexingCapability.Contains(Duplexing.TwoSidedLongEdge) Then
        printTicket.Duplexing = Duplexing.TwoSidedLongEdge
    End If

    If printCapabilities.StaplingCapability.Contains(Stapling.StapleDualLeft) Then
        printTicket.Stapling = Stapling.StapleDualLeft
    End If

    Return printTicket
End Function ' end:GetPrintTicketFromPrinter()

注釈

PrintCapabilitiesオブジェクトは、PrintCapabilities ドキュメントと呼ばれる特定の種類の XML ドキュメントを簡単に操作できる表現です。 後者は、プリンターのすべての機能とその現在の設定のスナップショットです。 たとえば、プリンターがカラー印刷をサポートしている場合、ドキュメントには色出力の処理方法を <PageOutputColor … > 設定する要素が含まれます。 要素は、 オブジェクトの プロパティPrintCapabilitiesによってOutputColorCapability表されます。 プリンターが色をサポートしていない場合、ドキュメントに要素はなく <PageOutputColor … >OutputColorCapability プロパティの値は です null。 PrintCapabilities ドキュメントは 、印刷スキーマに準拠している必要があります。

PrintCapabilitiesクラスを使用すると、アプリケーションは XML Stream オブジェクトを直接読み取ることなく、プリンターの機能を取得できます。

家庭とビジネスの両方でファイルプリンターとフォトプリンターの最も一般的な機能はすべて、 クラスによって PrintCapabilities カプセル化されています。 しかし、 印刷スキーマ は、より多くの、あまり一般的ではない機能を定義し、特殊な印刷デバイスの機能を処理するように拡張することができます。 そのため、 クラスと PrintCapabilities クラスはPrintTicket継承できませんが、 クラスまたは PrintCapabilities クラスで考慮されていない印刷デバイス機能を認識するように印刷スキーマをPrintTicket拡張できます。

メモPrintCapabilities PrintCapabilities ドキュメントを () パラメーターとしてStream受け取るコンストラクターを使用してオブジェクトを作成すると、そのドキュメント全体がオブジェクト内の非パブリック フィールドに格納されます。これには、クラスのパブリック プロパティPrintCapabilitiesで表されないあまり一般的でない機能を表す XML 要素も含まれます。 実際、PrintCapabilities ドキュメントを生成したドライバーが Print Schema のプライベート拡張機能を使用している場合、そのプライベートに定義されたマークアップも、パブリック以外の PrintCapabilities ドキュメントの一部として格納されます。

注意事項

名前空間内の System.Printing クラスは、Windows サービスまたはアプリケーションまたはサービス内での使用 ASP.NET サポートされていません。 これらのアプリケーションの種類の 1 つ内からこれらのクラスを使用しようとすると、サービスのパフォーマンスの低下や実行時の例外など、予期しない問題が発生する可能性があります。

Windows フォーム アプリケーションから印刷する場合は、 名前空間をSystem.Drawing.Printing参照してください。

コンストラクター

PrintCapabilities(Stream)

XML 印刷スキーマに準拠してプリンターの機能を指定する XML ストリーム (PrintCapabilities ドキュメントを格納) を使用して、PrintCapabilities クラスの新しいインスタンスを初期化します。

プロパティ

CollationCapability

プリンターの部単位印刷機能を識別する値のコレクションを取得します。

DeviceFontSubstitutionCapability

プリンターでコンピューターのフォントをプリンターのフォントに置き換えられるかどうか、置き換えられる場合にはどのような方法があるかを示す値のコレクションを取得します。

DuplexingCapability

プリンターで両面印刷を実行できるかどうか、実行できる場合にはどのような方法があるかを示す値のコレクションを取得します。

InputBinCapability

使用されている入力ビン (用紙トレイ) を示す値のコレクションを取得します。

MaxCopyCount

プリンターが 1 回の印刷ジョブで印刷できる最大部数を示す値を取得します。

OrientedPageMediaHeight

ページのイメージ可能領域の高さを示す値を取得します。高さは、ページの向きを基準とする縦のサイズです。

OrientedPageMediaWidth

ページのイメージ可能領域の幅を示す値を取得します。幅は、ページの向きを基準とする横のサイズです。

OutputColorCapability

色や灰色の網かけを含む内容を印刷する際にプリンターで使用できる方法を指定する値のコレクションを取得します。

OutputQualityCapability

プリンターでサポートされている出力品質の種類を示す値のコレクションを取得します。

PageBorderlessCapability

プリンターがメディアの端まで印刷できるかどうかを示す値のコレクションを取得します。

PageImageableArea

プリンターが使用できるページの領域を表すオブジェクトを取得します。

PageMediaSizeCapability

プリンターでサポートされている用紙やメディアのサイズを識別する PageMediaSize オブジェクトのコレクションを取得します。

PageMediaTypeCapability

プリンターでサポートされている用紙やその他のメディアの種類を識別する値のコレクションを取得します。

PageOrderCapability

プリンターで複数ページのドキュメントを印刷する際に使用できるページの順序 (前から後ろ、後ろから前、または両方) を示す値のコレクションを取得します。

PageOrientationCapability

プリンターでサポートされているページの向きを識別する値のコレクションを取得します。

PageResolutionCapability

プリンターでサポートされているページ解像度のレベルを識別する PageResolution オブジェクトのコレクションを取得します。

PageScalingFactorRange

プリンターでページ上の印刷イメージを拡大または縮小する際に使用する最大パーセンテージと最小パーセンテージを取得します。

PagesPerSheetCapability

用紙の片面に印刷するように選択できるページ数をそれぞれ識別する整数のコレクションを取得します。

PagesPerSheetDirectionCapability

用紙の片面に複数のページを印刷する際にプリンターでサポートされるパターンを識別する値のコレクションを取得します。

PhotoPrintingIntentCapability

プリンターで写真を印刷する際にサポートされる品質のオプションを識別する値のコレクションを取得します。

StaplingCapability

プリンターでサポートされている自動ステープル処理の種類を識別する値のコレクションを取得します。

TrueTypeFontModeCapability

プリンターでサポートされている TrueType フォントの処理方法を識別する値のコレクションを取得します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象