Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

PrintTicket.Stapling Property

Gets or sets a value indicating whether, and where, a printer staples multiple pages.

Namespace:  System.Printing
Assembly:  ReachFramework (in ReachFramework.dll)
'Declaration
Public Property Stapling As Nullable(Of Stapling)

Property Value

Type: System.Nullable(Of Stapling)
A Stapling value specifying how a printer staples the output.
ExceptionCondition
ArgumentOutOfRangeException

Calling code has attempted to set the property to a value that is not in the Stapling enumeration.

For example, a printer can place two staples on the left edge of a sheet of paper, or one staple in the upper left corner.

A Nothing value for this property means that this feature setting is not specified. Also, when the value is Nothing, the XML versions of the PrintTicket (see SaveTo and GetXmlStream) will not contain any markup for this feature.

This property corresponds to the Print Schema's JobStapleAllDocuments keyword, not the DocumentStaple keyword.

You can test for the options that the printer supports by using the StaplingCapability property.

The following example shows how to use this property when testing a printer's capabilities and configuring a 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>
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()

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.