PrintQueue.MergeAndValidatePrintTicket 方法

定义

合并两种 PrintTicket,保证所得的 PrintTicket 有效且不请求打印机所不支持的任何打印功能。

重载

MergeAndValidatePrintTicket(PrintTicket, PrintTicket)

合并两种 PrintTicket,保证所得的 PrintTicket 有效且不请求打印机所不支持的任何打印功能。

MergeAndValidatePrintTicket(PrintTicket, PrintTicket, PrintTicketScope)

合并两种 PrintTicket,保证所得的 PrintTicket 有效,不请求打印机所不支持的任何打印功能,且限于指定的作用域。

MergeAndValidatePrintTicket(PrintTicket, PrintTicket)

合并两种 PrintTicket,保证所得的 PrintTicket 有效且不请求打印机所不支持的任何打印功能。

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

参数

basePrintTicket
PrintTicket

第一种打印票证。

deltaPrintTicket
PrintTicket

第二种打印票证。 它可以是 null

返回

一个 ValidationResult,其中包括合并的 PrintTicket 和一个指示,该指示表明是否为了保证可行性而不得不更改其任何设置。

例外

至少有一个输入打印票证无效。

basePrintTicketnull

验证、合并和可行性检查操作失败。

示例

以下示例演示如何使用此方法合并两个打印票证并响应 ValidationResult 返回的 。

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

注解

方法生成可行的打印票证;即,不请求打印机不支持的打印功能的票证。 方法首先根据打印架构验证两个输入 打印票证。 如果其中一个无效,则会引发异常。

然后合并这两个票证。 如果它们具有特定属性的不同值,则生成的合并票证最初使用增量票证的值。

然后,根据打印机的实际功能检查合并的票证。 如果票证中的任何设置与打印机的功能不兼容,则打印机驱动程序会使用所需的任何逻辑更改这些设置。 通常,它将用户或打印机的默认值替换为设置。 因此,驱动程序的替换值源与 不是相同的票证 basePrintTicket,那么合并的票证可能具有一些与这两个输入票证不同的设置。 如果打印机驱动程序必须更改任何设置,则会在 的 ValidationResult属性中ConflictStatus报告此事实。

若要根据打印队列的默认设置进行合并和验证,应将 设置为 basePrintTicketDefaultPrintTicketUserPrintTicket

参数 deltaPrintTicket 可以是 null,在这种情况下, basePrintTicket 会验证、检查可行性并返回(可能包含更改)。

如果重载为 MergeAndValidatePrintTicketdeltaPrintTicket 则返回 的 和 PrintTicket 中的 ValidationResult 都有作业范围。 若要指定其他范围,请使用此方法的其他重载。

适用于

MergeAndValidatePrintTicket(PrintTicket, PrintTicket, PrintTicketScope)

合并两种 PrintTicket,保证所得的 PrintTicket 有效,不请求打印机所不支持的任何打印功能,且限于指定的作用域。

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

参数

basePrintTicket
PrintTicket

第一种打印票证。

deltaPrintTicket
PrintTicket

第二种打印票证。 它可以是 null

scope
PrintTicketScope

用于表示 deltaPrintTicket 的作用域和 ValidationResult 中返回的打印票证的作用域是一个页面、文档,还是整个作业的值。

返回

一个 ValidationResult,其中包括合并的 PrintTicket 和一个指示,该指示表明是否为了保证可行性而不得不更改其任何设置。

例外

至少有一个输入打印票证无效。

basePrintTicketnull

scope 参数不含有效的 PrintTicketScope 值。

验证、合并和可行性检查操作失败。

注解

方法生成可行的打印票证;即,不请求打印机不支持的打印功能的票证。 方法首先根据打印架构验证两个输入 打印票证。 如果其中一个无效,则会引发异常。

然后合并这两个票证。 如果它们具有特定属性的不同值,则生成的合并票证最初使用增量票证的值。

然后,根据打印机的实际功能检查合并的票证。 如果票证中的任何设置与打印机的功能不兼容,则打印机驱动程序会使用所需的任何逻辑更改这些设置。 通常,它将用户或打印机的默认值替换为设置。 因此,驱动程序的替换值源与 不是相同的票证 basePrintTicket,那么合并的票证可能具有一些与这两个输入票证不同的设置。 如果打印机驱动程序必须更改任何设置,则会在 的 ValidationResult属性中ConflictStatus报告此事实。

若要根据打印队列的默认设置进行合并和验证,应将 设置为 basePrintTicketDefaultPrintTicketUserPrintTicket

参数 deltaPrintTicket 可以是 null,在这种情况下, basePrintTicket 会验证、检查可行性并返回(可能包含更改)。

scope如果 是作业,则在 中ValidationResult返回的打印票证可以包含带有作业、文档和页面前缀的打印架构参数。 scope如果 是文档,则忽略 中的deltaPrintTicket每个作业设置,返回的票证可以包含带有 Document 和 Page 前缀的参数。 scope如果 是页面,则忽略中的deltaPrintTicket每作业设置和每文档设置,返回的票证可以包含仅包含 Page 前缀的参数。

适用于