共用方式為


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

第一個 Print Ticket。

deltaPrintTicket
PrintTicket

第二個 Print Ticket。 這可以是 null

傳回

ValidationResult,包含合併的 PrintTicket,以及是否需要變更其任何設定以確保可用性的指示。

例外狀況

至少一個輸入 Print Ticket 無效。

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證可能會有一些與兩個輸入票證不同的設定。 如果印表機驅動程式必須變更任何設定,則會在 ConflictStatusValidationResult屬性中報告這項事實。

若要根據列印佇列的預設設定合併和驗證,您應該將 設定 basePrintTicketDefaultPrintTicketUserPrintTicket

參數 deltaPrintTicket 可以是 null,在此情況下 basePrintTicket ,會驗證 、檢查是否可行,並傳回,可能是變更。

使用 這個 多 MergeAndValidatePrintTicket載 時, deltaPrintTicket 傳回 的和 PrintTicketValidationResult 具有整個作業範圍。 若要指定不同的範圍,請使用此方法的其他多載。

適用於

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

第一個 Print Ticket。

deltaPrintTicket
PrintTicket

第二個 Print Ticket。 這可以是 null

scope
PrintTicketScope

這個值表示 deltaPrintTicket 範圍和 ValidationResult 中傳回之 Print Ticket 的範圍是一個頁面、一個文件,還是整個工作。

傳回

ValidationResult,包含合併的 PrintTicket,以及是否需要變更其任何設定以確保可用性的指示。

例外狀況

至少一個輸入 Print Ticket 無效。

basePrintTicketnull

scope 參數沒有有效的 PrintTicketScope 值。

驗證、合併和可用性檢查作業失敗。

備註

方法會產生可行的列印票證;也就是說,不要求印表機不支援的印表功能票證。 方法會先針對 列印架構驗證兩個輸入列印票證。 如果其中一個無效,則會擲回例外狀況。

接著會合併這兩個票證。 如果特定屬性的值不同,則產生的合併票證一開始會使用差異票證的值。

然後,系統會根據印表機的實際功能檢查合併的票證。 如果票證中的任何設定與印表機的功能不相容,則列印機驅動程式會使用想要的任何邏輯來變更這些設定。 一般而言,它會取代使用者或印表機的預設值來取代設定。 驅動程式的替代值來源與 不同,則合併的票 basePrintTicket證可能會有一些與兩個輸入票證不同的設定。 如果印表機驅動程式必須變更任何設定,則會在 ConflictStatusValidationResult屬性中報告這項事實。

若要根據列印佇列的預設設定合併和驗證,您應該將 設定 basePrintTicketDefaultPrintTicketUserPrintTicket

參數 deltaPrintTicket 可以是 null,在此情況下 basePrintTicket ,會驗證 、檢查是否可行,並傳回,可能是變更。

scope如果 是作業,則 中ValidationResult傳回的列印票證可以包含具有作業、文件和頁面前置詞的列印架構參數。 scope如果 是檔,則會忽略 中的deltaPrintTicket個別作業設定,而傳回的票證可以包含具有 Document 和 Page 前置詞的參數。 scope如果 是頁面,則會忽略 中的deltaPrintTicket個別作業設定和個別檔設定,而傳回的票證只能包含具有Page前置詞的參數。

適用於