PrintQueue.DefaultPrintTicket PrintQueue.DefaultPrintTicket PrintQueue.DefaultPrintTicket PrintQueue.DefaultPrintTicket Property

Definición

Obtiene o establece las opciones de impresora predeterminadas asociadas a PrintQueue.Gets or sets the default printer options associated with this PrintQueue.

public:
 virtual property System::Printing::PrintTicket ^ DefaultPrintTicket { System::Printing::PrintTicket ^ get(); void set(System::Printing::PrintTicket ^ value); };
[get: System.Security.SecurityCritical]
public virtual System.Printing.PrintTicket DefaultPrintTicket { get; set; }
member this.DefaultPrintTicket : System.Printing.PrintTicket with get, set
Public Overridable Property DefaultPrintTicket As PrintTicket

Valor de propiedad

Valor de PrintTicket predeterminado para la cola de impresión; o null si se ha producido un error en la cola de impresión.The default PrintTicket for the print queue; or null if an error has occurred in the print queue.

Ejemplos

En el ejemplo siguiente se muestra cómo utilizar esta propiedad mientras se prueban las capacidades de una impresora y se configura un trabajo de impresión para aprovecharse de ellas.The following example shows how to use this property while 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>
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()

Comentarios

El valor PrintTicket predeterminado especifica las opciones CopyCountdel trabajo de impresión Duplexing, Staplingcomo, PageOrientation,, y otras.The default PrintTicket specifies print job options such as CopyCount, PageOrientation, Duplexing, Stapling, and others.

Cada PrintQueue una de ellas DefaultPrintTicketmantiene su propia.Each PrintQueue maintains its own DefaultPrintTicket.

En el funcionamiento normal DefaultPrintTicket , la propiedad PrintTicketdevuelve un.In normal operation the DefaultPrintTicket property returns a PrintTicket. Si detecta un estado no válido, DefaultPrintTicket devuelve null. PrintQueueIf the PrintQueue detects an invalid state, DefaultPrintTicket returns null. Si DefaultPrintTicket devuelvenull, la aplicación debe mostrar un cuadro de diálogo de usuario informativo que indica que se ha producido un error en esta cola de impresión y que el trabajo de impresión debe reiniciarse con la salida dirigida a una cola de impresión diferente.If DefaultPrintTicket returns null, the application should display an informational user dialog that an error has occurred on this print queue and that the print job should be restarted with the output directed to a different print queue.

Al obtener o establecer DefaultPrintTicket la propiedad no se valida PrintTicketel.Getting or setting the DefaultPrintTicket property does not validate the PrintTicket. El MergeAndValidatePrintTicket método se puede utilizar para validar un PrintTicket.The MergeAndValidatePrintTicket method can be used to validate a PrintTicket.

Se aplica a

Consulte también: