PrintQueue.MergeAndValidatePrintTicket Método

Definición

Combina dos PrintTicket y garantiza que el objeto PrintTicket resultante sea válido, y no pregunta si hay alguna funcionalidad de impresión que la impresora no admita.Merges two PrintTickets and guarantees that the resulting PrintTicket is valid and does not ask for any printing functionality that the printer does not support.

Sobrecargas

MergeAndValidatePrintTicket(PrintTicket, PrintTicket)

Combina dos PrintTicket y garantiza que el objeto PrintTicket resultante sea válido, y no pregunta si hay alguna funcionalidad de impresión que la impresora no admita.Merges two PrintTickets and guarantees that the resulting PrintTicket is valid and does not ask for any printing functionality that the printer does not support.

MergeAndValidatePrintTicket(PrintTicket, PrintTicket, PrintTicketScope)

Combina dos objetos PrintTicket y garantiza que el objeto PrintTicket resultante sea válido, no pregunta si hay alguna funcionalidad de impresión que la impresora no admita y se limita al ámbito especificado.Merges two PrintTickets and guarantees that the resulting PrintTicket is valid, does not ask for any printing functionality that the printer does not support, and is limited to the specified scope.

MergeAndValidatePrintTicket(PrintTicket, PrintTicket)

Combina dos PrintTicket y garantiza que el objeto PrintTicket resultante sea válido, y no pregunta si hay alguna funcionalidad de impresión que la impresora no admita.Merges two PrintTickets and guarantees that the resulting PrintTicket is valid and does not ask for any printing functionality that the printer does not support.

public:
 System::Printing::ValidationResult MergeAndValidatePrintTicket(System::Printing::PrintTicket ^ basePrintTicket, System::Printing::PrintTicket ^ deltaPrintTicket);
public System.Printing.ValidationResult MergeAndValidatePrintTicket (System.Printing.PrintTicket basePrintTicket, System.Printing.PrintTicket deltaPrintTicket);
member this.MergeAndValidatePrintTicket : System.Printing.PrintTicket * System.Printing.PrintTicket -> System.Printing.ValidationResult
Public Function MergeAndValidatePrintTicket (basePrintTicket As PrintTicket, deltaPrintTicket As PrintTicket) As ValidationResult

Parámetros

basePrintTicket
PrintTicket

Primera solicitud de impresión.The first print ticket.

deltaPrintTicket
PrintTicket

Segunda solicitud de impresión.The second print ticket. Puede ser null.This can be null.

Devoluciones

ValidationResult que incluye el objeto PrintTicket combinado y una indicación de si ha habido que cambiar algún valor de configuración para garantizar la viabilidad.A ValidationResult that includes the merged PrintTicket and an indication of whether any of its settings had to be changed to guarantee viability.

Excepciones

Por lo menos una de las solicitudes de impresión de entrada no es válida.At least one of the input print tickets is not valid.

El valor de basePrintTicket es null.The basePrintTicket is null.

Se produjo un error en la operación de comprobación de validación, combinación y viabilidad.The validation, merger, and viability checking operation failed.

Ejemplos

En el ejemplo siguiente se muestra cómo utilizar este método para combinar dos solicitudes de impresión y responder al ValidationResult que se devuelve.The following example shows how to use this method to merge two print tickets and respond to the ValidationResult that is returned.

/// <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>
static private void ChangePrintTicketSetting(PrintQueue queue)
{
    //
    // Obtain the printer's PrintCapabilities so we can determine whether or not
    // duplexing printing is supported by the printer.
    //
    PrintCapabilities printcap = 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))
    {
        //
        // To change the user-default PrintTicket, we can first create a delta PrintTicket with
        // the new duplexing setting.
        //
        PrintTicket deltaTicket = 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.
        //
        ValidationResult result = 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)
        {
            //
            // Set the printer's user-default PrintTicket and commit the set operation.
            //
            queue.UserPrintTicket = result.ValidatedPrintTicket;
            queue.Commit();
            Console.WriteLine("PrintTicket new duplexing setting is set on '{0}'.", queue.FullName);
        }
        else
        {
            //
            // 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);
        }
    }
    else
    {
        //
        // 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);
    }
}
''' <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
            queue.Commit()
            Console.WriteLine("PrintTicket new duplexing setting is set on '{0}'.", queue.FullName)
        Else
            '
            ' 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
    Else
        '
        ' 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

Comentarios

El método genera una solicitud de impresión viable; es decir, un vale que no solicita características de impresión que la impresora no admite.The method produces a viable print ticket; that is, a ticket that does not request printing features that the printer does not support. El método valida primero los dos vales de impresión de entrada en el esquema de impresión.The method first validates the two input print tickets against the Print Schema. Si no es válido, se produce una excepción.If either is invalid, an exception is thrown.

A continuación, se combinan los dos vales.The two tickets are then merged. Si tienen valores diferentes para una propiedad determinada, el vale combinado resultante usa inicialmente el valor del vale Delta.If they have different values for a particular property then the resulting merged ticket initially uses the value of the delta ticket.

A continuación, se comprueba el vale combinado con las capacidades reales de la impresora.The merged ticket is then checked against the actual capabilities of the printer. Si alguna de las opciones del vale es incompatible con las capacidades de la impresora, el controlador de la impresora cambia dicha configuración con la lógica que desee.If any settings in the ticket are incompatible with the printer's capabilities, then the printer driver changes those settings by using whatever logic it wants. Normalmente, sustituye el valor predeterminado de la impresora o del usuario para la configuración.Typically, it substitutes the user's or printer's default value for the setting. El origen del controlador de los valores sustitutos no es el mismo vale que basePrintTicket. después, el vale combinado podría tener algunos valores de configuración distintos de los dos vales de entrada.It the driver's source of substitute values is not the same ticket as basePrintTicket, then the merged ticket might have some settings that are different from both of the input tickets. Si el controlador de impresora tiene que cambiar algún valor de configuración, este hecho se registra en la propiedad ConflictStatus de la ValidationResult.If the printer driver has to change any settings then this fact is reported in the ConflictStatus property of the ValidationResult.

Para combinar y validar en función de la configuración predeterminada de una cola de impresión, debe establecer basePrintTicket en el DefaultPrintTicket o UserPrintTicket.To merge and validate based on a print queue's default settings, you should set basePrintTicket to the DefaultPrintTicket or the UserPrintTicket.

El parámetro deltaPrintTicket puede ser null, en cuyo caso se valida el basePrintTicket, se comprueba la viabilidad y se devuelve, posiblemente con cambios.The deltaPrintTicket parameter can be null, in which case the basePrintTicket is validated, checked for viability, and returned, possibly with changes.

Con esta sobrecarga de MergeAndValidatePrintTicket, tanto el deltaPrintTicket como el PrintTicket del ValidationResult que se devuelven tienen ámbito de trabajo amplio.With this overload of MergeAndValidatePrintTicket, both the deltaPrintTicket and the PrintTicket in the ValidationResult that is returned have job wide scope. Para especificar un ámbito diferente, use la otra sobrecarga de este método.To specify a different scope use the other overload of this method.

MergeAndValidatePrintTicket(PrintTicket, PrintTicket, PrintTicketScope)

Combina dos objetos PrintTicket y garantiza que el objeto PrintTicket resultante sea válido, no pregunta si hay alguna funcionalidad de impresión que la impresora no admita y se limita al ámbito especificado.Merges two PrintTickets and guarantees that the resulting PrintTicket is valid, does not ask for any printing functionality that the printer does not support, and is limited to the specified scope.

public:
 System::Printing::ValidationResult MergeAndValidatePrintTicket(System::Printing::PrintTicket ^ basePrintTicket, System::Printing::PrintTicket ^ deltaPrintTicket, System::Printing::PrintTicketScope scope);
public System.Printing.ValidationResult MergeAndValidatePrintTicket (System.Printing.PrintTicket basePrintTicket, System.Printing.PrintTicket deltaPrintTicket, System.Printing.PrintTicketScope scope);
member this.MergeAndValidatePrintTicket : System.Printing.PrintTicket * System.Printing.PrintTicket * System.Printing.PrintTicketScope -> System.Printing.ValidationResult
Public Function MergeAndValidatePrintTicket (basePrintTicket As PrintTicket, deltaPrintTicket As PrintTicket, scope As PrintTicketScope) As ValidationResult

Parámetros

basePrintTicket
PrintTicket

Primera solicitud de impresión.The first print ticket.

deltaPrintTicket
PrintTicket

Segunda solicitud de impresión.The second print ticket. Puede ser null.This can be null.

scope
PrintTicketScope

Valor que indica si el ámbito de deltaPrintTicket y el ámbito de la solicitud de impresión devuelta en ValidationResult es una página, un documento o el trabajo completo.A value indicating whether the scope of deltaPrintTicket, and the scope of the print ticket returned in the ValidationResult, is a page, a document, or the whole job.

Devoluciones

ValidationResult que incluye el objeto PrintTicket combinado y una indicación de si ha habido que cambiar algún valor de configuración para garantizar la viabilidad.A ValidationResult that includes the merged PrintTicket and an indication of whether any of its settings had to be changed to guarantee viability.

Excepciones

Por lo menos una de las solicitudes de impresión de entrada no es válida.At least one of the input print tickets is not valid.

El valor de basePrintTicket es null.The basePrintTicket is null.

El parámetro scope no tiene un valor de PrintTicketScope válido.The scope parameter does not have a valid PrintTicketScope value.

Se produjo un error en la operación de comprobación de validación, combinación y viabilidad.The validation, merger, and viability checking operation failed.

Comentarios

El método genera una solicitud de impresión viable; es decir, un vale que no solicita características de impresión que la impresora no admite.The method produces a viable print ticket; that is, a ticket that does not request printing features that the printer does not support. El método valida primero los dos vales de impresión de entrada en el esquema de impresión.The method first validates the two input print tickets against the Print Schema. Si no es válido, se produce una excepción.If either is invalid, an exception is thrown.

A continuación, se combinan los dos vales.The two tickets are then merged. Si tienen valores diferentes para una propiedad determinada, el vale combinado resultante usa inicialmente el valor del vale Delta.If they have different values for a particular property then the resulting merged ticket initially uses the value of the delta ticket.

A continuación, se comprueba el vale combinado con las capacidades reales de la impresora.The merged ticket is then checked against the actual capabilities of the printer. Si alguna de las opciones del vale es incompatible con las capacidades de la impresora, el controlador de la impresora cambia dicha configuración con la lógica que desee.If any settings in the ticket are incompatible with the printer's capabilities, then the printer driver changes those settings by using whatever logic it wants. Normalmente, sustituye el valor predeterminado de la impresora o del usuario para la configuración.Typically, it substitutes the user's or printer's default value for the setting. El origen del controlador de los valores sustitutos no es el mismo vale que basePrintTicket. después, el vale combinado podría tener algunos valores de configuración distintos de los dos vales de entrada.It the driver's source of substitute values is not the same ticket as basePrintTicket, then the merged ticket might have some settings that are different from both of the input tickets. Si el controlador de impresora tiene que cambiar algún valor de configuración, este hecho se registra en la propiedad ConflictStatus de la ValidationResult.If the printer driver has to change any settings then this fact is reported in the ConflictStatus property of the ValidationResult.

Para combinar y validar en función de la configuración predeterminada de una cola de impresión, debe establecer basePrintTicket en el DefaultPrintTicket o UserPrintTicket.To merge and validate based on a print queue's default settings, you should set basePrintTicket to the DefaultPrintTicket or the UserPrintTicket.

El parámetro deltaPrintTicket puede ser null, en cuyo caso se valida el basePrintTicket, se comprueba la viabilidad y se devuelve, posiblemente con cambios.The deltaPrintTicket parameter can be null, in which case the basePrintTicket is validated, checked for viability, and returned, possibly with changes.

Si el scope es un trabajo, el vale de impresión devuelto en el ValidationResult puede incluir parámetros de esquema de impresión con prefijos de trabajo, documento y página.If the scope is a job, then the print ticket returned in the ValidationResult can include Print Schema parameters with Job, Document, and Page prefixes. Si el scope es un documento, se omite la configuración por trabajo de deltaPrintTicket y el vale devuelto puede incluir parámetros con prefijos de documento y de página.If the scope is a document, then per-job settings in deltaPrintTicket are ignored, and the returned ticket can include parameters with Document and Page prefixes. Si el scope es una página, se omite la configuración por trabajo y la configuración por documento en deltaPrintTicket, y el vale devuelto puede incluir parámetros solo con el prefijo de página.If the scope is a page, then the per-job settings and the per-document settings in deltaPrintTicket are ignored, and the returned ticket can include parameters with only the Page prefix.

Se aplica a