This documentation is archived and is not being maintained.

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)

public Nullable<Stapling> Stapling { get; set; }
/** @property */
public Nullable<Stapling> get_Stapling ()

/** @property */
public void set_Stapling (Nullable<Stapling> value)

public function get Stapling () : Nullable<Stapling>

public function set Stapling (value : Nullable<Stapling>)

You cannot use this property in XAML.

Property Value

A Stapling value specifying how a printer staples the output.

Exception typeCondition

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 a null reference (Nothing in Visual Basic) value for this property means that this feature setting is not specified. Also, when the value is a null reference (Nothing in Visual Basic), 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. For the complete example, see Creating an XPS Document Sample.

// ---------------------- 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()

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Show: