Duplexing Duplexing Duplexing Duplexing Enum

定义

指定打印机是使用单面打印,还是使用某种类型的双面(双工打印)打印。Specifies whether a printer uses one-sided printing or some type of two-sided (duplex) printing.

public enum class Duplexing
public enum Duplexing
type Duplexing = 
Public Enum Duplexing
继承

字段

OneSided OneSided OneSided OneSided 1

仅在每张纸的单面上输出打印。Output prints on only one side of each sheet.

TwoSidedLongEdge TwoSidedLongEdge TwoSidedLongEdge TwoSidedLongEdge 3

在每张纸的两个面上输出打印,其沿着平行于 MediaSizeHeight 的边缘翻转。Output prints on both sides of each sheet, which flips along the edge parallel to the MediaSizeHeight.

TwoSidedShortEdge TwoSidedShortEdge TwoSidedShortEdge TwoSidedShortEdge 2

在每张纸的两个面上输出打印,其沿着平行于 MediaSizeWidth 的边缘翻转。Output prints on both sides of each sheet, which flips along the edge parallel to MediaSizeWidth.

Unknown Unknown Unknown Unknown 0

该功能(其选项由此枚举表示)设置为未在打印架构中定义的选项。The feature (whose options are represented by this enumeration) is set to an option not defined in the Print Schema.

示例

下面的示例演示如何测试打印机的功能, 以及如何配置打印作业以利用这些功能。The following example shows how to test a printer's capabilities and configure the print job to take advantage of them. .

// ---------------------- 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^ printCapabilites = printQueue->GetPrintCapabilities();

   // Modify PrintTicket
   if (printCapabilites->CollationCapability->Contains(Collation::Collated))
   {
      printTicket->Collation = Collation::Collated;
   }
   if (printCapabilites->DuplexingCapability->Contains(Duplexing::TwoSidedLongEdge))
   {
      printTicket->Duplexing = Duplexing::TwoSidedLongEdge;
   }
   if (printCapabilites->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 printCapabilites = printQueue.GetPrintCapabilities();

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

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

    if (printCapabilites.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 printCapabilites As PrintCapabilities = printQueue.GetPrintCapabilities()

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

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

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

    Return printTicket
End Function ' end:GetPrintTicketFromPrinter()

注解

使用此类型的值主要用于以下目的:Use the values of this type primarily for these purposes:

  • 作为的属性的DuplexingCapability PrintCapabilities集合的成员, 这些值表示打印机支持的一种单面打印和两次打印。As members of the DuplexingCapability collection, which is a property of PrintCapabilities, these values indicate the kinds of one-sided and two-sided printing that the printer supports.

  • 作为的Duplexing属性PrintTicket的值, 它们指示打印机使用单面打印或某种类型的双面打印。As the value of the Duplexing property of a PrintTicket, they direct the printer to use one-sided printing or some kind of two-sided printing.

PrintCapabilities对象的属性中从不使用未知值。The Unknown value is never used in properties of PrintCapabilities objects.

永远不应将PrintTicket属性设置为 "未知"。You should never set a PrintTicket property to Unknown. 如果生成应用PrintTicket程序的其他部分创建了一个PrintTicket 文档, 该文档将双面打印功能设置为无法识别的双面选项 (即, 未在PrintTicket 打印架构中定义的选项), 则使用该文档构造的应用程序中的对象将作为该Duplexing属性的值未知。If some other PrintTicket producing application has created a PrintTicket document that sets the duplexing feature to an unrecognized duplexing option (that is, an option that is not defined in the Print Schema), then a PrintTicket object in your application that is constructed with that document will have Unknown as the value of the Duplexing property.

PrintTicket PrintCapabilities尽管和PrintTicket PrintCapabilities类不能被继承, 但你可以扩展打印架构来识别在或类中不考虑的打印设备功能。Although the PrintTicket and PrintCapabilities classes cannot be inherited, you can extend the Print Schema to recognize print device features that are not accounted for in the PrintTicket or PrintCapabilities classes. 有关详细信息,请参阅操作说明:扩展打印架构并创建新的打印系统类For more information see How to: Extend the Print Schema and Create New Print System Classes.

适用于

另请参阅