PrintQueue.GetPrintCapabilities Method ()


Gets a PrintCapabilities object that identifies the capabilities of the printer.

Namespace:   System.Printing
Assembly:  System.Printing (in System.Printing.dll)

Public Function GetPrintCapabilities As PrintCapabilities

Return Value

Type: System.Printing.PrintCapabilities

A PrintCapabilities object that specifies what the printer can and cannot do, such as two-sided coping or automatic stapling.

Exception Condition

The PrintCapabilities object could not be retrieved.

The following example shows how to use this method while merging two print tickets.

''' <summary>
''' Changes the user-default PrintTicket setting of the specified print queue.
''' </summary>
''' <param name="queue">the printer whose user-default PrintTicket setting needs to be changed</param>
Private Shared Sub ChangePrintTicketSetting(ByVal queue As PrintQueue)
	' Obtain the printer's PrintCapabilities so we can determine whether or not
	' duplexing printing is supported by the printer.
	Dim printcap As PrintCapabilities = queue.GetPrintCapabilities()

	' The printer's duplexing capability is returned as a read-only collection of duplexing options
	' that can be supported by the printer. If the collection returned contains the duplexing
	' option we want to set, it means the duplexing option we want to set is supported by the printer,
	' so we can make the user-default PrintTicket setting change.
	If printcap.DuplexingCapability.Contains(Duplexing.TwoSidedLongEdge) Then
		' To change the user-default PrintTicket, we can first create a delta PrintTicket with
		' the new duplexing setting.
		Dim deltaTicket As New PrintTicket()
		deltaTicket.Duplexing = Duplexing.TwoSidedLongEdge

		' Then merge the delta PrintTicket onto the printer's current user-default PrintTicket,
		' and validate the merged PrintTicket to get the new PrintTicket we want to set as the
		' printer's new user-default PrintTicket.
		Dim result As ValidationResult = queue.MergeAndValidatePrintTicket(queue.UserPrintTicket, deltaTicket)

		' The duplexing option we want to set could be constrained by other PrintTicket settings
		' or device settings. We can check the validated merged PrintTicket to see whether the
		' the validation process has kept the duplexing option we want to set unchanged.
		If result.ValidatedPrintTicket.Duplexing = Duplexing.TwoSidedLongEdge Then
			' Set the printer's user-default PrintTicket and commit the set operation.
			queue.UserPrintTicket = result.ValidatedPrintTicket
			Console.WriteLine("PrintTicket new duplexing setting is set on '{0}'.", queue.FullName)
			' The duplexing option we want to set has been changed by the validation process
			' when it was resolving setting constraints.
			Console.WriteLine("PrintTicket new duplexing setting is constrained on '{0}'.", queue.FullName)
		End If
		' If the printer doesn't support the duplexing option we want to set, skip it.
		Console.WriteLine("PrintTicket new duplexing setting is not supported on '{0}'.", queue.FullName)
	End If
End Sub


for permission to get print capabilities. Associated enumeration: DefaultPrinting

.NET Framework
Available since 3.0
Return to top