Duplexing 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定打印机是使用单面打印,还是使用某种类型的双面(双工打印)打印。
public enum class Duplexing
public enum Duplexing
type Duplexing =
Public Enum Duplexing
- 继承
字段
OneSided | 1 | 仅在每张纸的单面上输出打印。 |
TwoSidedLongEdge | 3 | 在每张纸的两个面上输出打印,其沿着平行于 MediaSizeHeight 的边缘翻转。 |
TwoSidedShortEdge | 2 | 在每张纸的两个面上输出打印,其沿着平行于 MediaSizeWidth 的边缘翻转。 |
Unknown | 0 | 该功能(其选项由此枚举表示)设置为未在 打印架构中定义的选项。 |
示例
以下示例演示如何测试打印机的功能,以及如何配置打印作业以利用这些功能。 .
// ---------------------- 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()
注解
使用此类型的值主要用于以下目的:
作为 集合的成员 DuplexingCapability (即 的 PrintCapabilities属性),这些值指示打印机支持的单面打印和双面打印类型。
作为 的 PrintTicket属性的值Duplexing,它们指示打印机使用单面打印或某种双面打印。
未知值永远不会在 对象的属性PrintCapabilities中使用。
切勿将 PrintTicket 属性设置为 Unknown。 如果其他 PrintTicket 一些生成应用程序创建了 PrintTicket 文档 ,该文档将双工功能设置为无法识别的双工选项 (即 打印架构) 中未定义的选项,则 PrintTicket 应用程序中使用该文档构造的对象将具有 Unknown 作为 属性的值 Duplexing 。
PrintTicket尽管 无法继承 和 PrintCapabilities 类,但你可以扩展打印架构以识别 未在 或 PrintCapabilities 类中PrintTicket考虑的打印设备功能。 有关详细信息 ,请参阅如何:扩展打印架构和创建新的打印系统类。