none
I need a detailed example of how to use printTickets in printQueue.addJob .Net 4.5 RRS feed

  • Question

  • Code... In the call to addJob, the printTicket gets ignored. This is server side STA threaded on an IIS7.5 box operating under a domain app pool identity or user impersonation depending on mode. As I say, the ticket gets ignored.

    PrintTicket ptclone = printQueue.UserPrintTicket.Clone();

    PrintTicket pt = GetPrintTicketForJob(ptclone, myPrintJob.trayMediaSize, myPrintJob.trayNameSpace, myPrintJob.trayUri); //my method for resolving trays

    ValidationResult vr= printQueue.MergeAndValidatePrintTicket(ptclone, pt, PrintTicketScope.JobScope);

    PrintSystemJobInfo pj = printQueue.AddJob(myPrintJob.path, myPrintJob.fileName, false, vr.ValidatedPrintTicket);

    The code below works but I'm not happy with it...

    PrintTicket ptclone = printQueue.UserPrintTicket.Clone();

    PrintTicket pt = GetPrintTicketForJob(ptclone, myPrintJob.trayMediaSize, myPrintJob.trayNameSpace, myPrintJob.trayUri);

    ValidationResult vr= printQueue.MergeAndValidatePrintTicket(ptclone, pt, PrintTicketScope.JobScope);

    //different below using the .Net 4 version

    printQueue.UserPrintTicket = vr.ValidatedPrintTicket;

    PrintSystemJobInfo pj = printQueue.AddJob(myPrintJob.path, myPrintJob.fileName, false);

    Can you give me a functioning example of how this is supposed to work in .Net 4.5 please?


    • Edited by nomadNet Wednesday, March 20, 2013 5:58 AM
    Wednesday, March 20, 2013 5:56 AM

Answers

  • My bad....

    original code...

    PrintTicket ptclone = printQueue.UserPrintTicket.Clone();

    PrintTicket pt = GetPrintTicketForJob(ptclone, myPrintJob.trayMediaSize, myPrintJob.trayNameSpace, myPrintJob.trayUri); //my method for resolving trays

    ValidationResult vr= printQueue.MergeAndValidatePrintTicket(ptclone, pt, PrintTicketScope.JobScope);

    PrintSystemJobInfo pj = printQueue.AddJob(myPrintJob.path, myPrintJob.fileName, false, vr.ValidatedPrintTicket);

    the correct code for doing this is...

    PrintTicket ptclone = printQueue.UserPrintTicket; <---Note no Clone()

    //If you clone, although your job's current settings are correct, the userPrintTicket overrides your settings

    PrintTicket pt = GetPrintTicketForJob(ptclone, myPrintJob.trayMediaSize, myPrintJob.trayNameSpace, myPrintJob.trayUri); //my method for resolving trays

    //Oh, just so you know...if you have multiple trays with the same media size in them you need to specifically target the correct tray, see Witters World blog for details on how to do this.

    ValidationResult vr= printQueue.MergeAndValidatePrintTicket(ptclone, pt, PrintTicketScope.JobScope);

    PrintSystemJobInfo pj = printQueue.AddJob(myPrintJob.path, myPrintJob.fileName, false, vr.ValidatedPrintTicket);

    Wednesday, March 20, 2013 9:43 AM

All replies

  • My bad....

    original code...

    PrintTicket ptclone = printQueue.UserPrintTicket.Clone();

    PrintTicket pt = GetPrintTicketForJob(ptclone, myPrintJob.trayMediaSize, myPrintJob.trayNameSpace, myPrintJob.trayUri); //my method for resolving trays

    ValidationResult vr= printQueue.MergeAndValidatePrintTicket(ptclone, pt, PrintTicketScope.JobScope);

    PrintSystemJobInfo pj = printQueue.AddJob(myPrintJob.path, myPrintJob.fileName, false, vr.ValidatedPrintTicket);

    the correct code for doing this is...

    PrintTicket ptclone = printQueue.UserPrintTicket; <---Note no Clone()

    //If you clone, although your job's current settings are correct, the userPrintTicket overrides your settings

    PrintTicket pt = GetPrintTicketForJob(ptclone, myPrintJob.trayMediaSize, myPrintJob.trayNameSpace, myPrintJob.trayUri); //my method for resolving trays

    //Oh, just so you know...if you have multiple trays with the same media size in them you need to specifically target the correct tray, see Witters World blog for details on how to do this.

    ValidationResult vr= printQueue.MergeAndValidatePrintTicket(ptclone, pt, PrintTicketScope.JobScope);

    PrintSystemJobInfo pj = printQueue.AddJob(myPrintJob.path, myPrintJob.fileName, false, vr.ValidatedPrintTicket);

    Wednesday, March 20, 2013 9:43 AM
  • Hi Nomad,

    Thank you for posting on this forum.

    I am trying to involve some other one into this case, wait it patiently, please.

    Thank you.


    Mike Feng
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, March 21, 2013 6:45 AM
    Moderator